On static export, links fail but reload works
See original GitHub issueWhen I use the static export of my site, all links fail, but if I click reload the page loads.
The problem lies in the getInitialProps
where I fetch information from an api endpoint of my server. In development mode it is running and everything works OK.
If I export a static version of my site, all links fail because the server on getInitialProps
is not reachable. But if I click reload the page then works fine and renders the information that was fetched when the server api endpoint was available.
System information
- OS: mac osx 10.13.4
- Browser (if applies) chrome
- Version of Next.js: [e.g. 6.0.2]
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:5 (4 by maintainers)
Top Results From Across the Web
On static export, links fail but reload works · Issue #4384
When I use the static export of my site, all links fail, but if I click reload the page loads. The problem lies...
Read more >static export in next js doesn't load when i reload the page
I will explain by using my code example: My package.json contains this script: "build": "next build && next export" .
Read more >Advanced Features: Static HTML Export
Export your Next.js app to static HTML, and run it standalone without the need of a Node.js server.
Read more >Parcel
It statically analyzes the imports and exports of each module, and removes everything that isn't used. Tree shaking even works across dynamic import() ......
Read more >How to Solve the Chunk Load Error in JavaScript
If you are encountering this error as a user of an application, the most simple way to resolve it is to clear your...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think this is the same issue as https://github.com/zeit/next.js/issues/3085#issuecomment-471192394
After working around this issue I noticed that
<Link>
causesgetInitialProps
to run but not a normal link<a>
. I could switch to normal links, but doing so will make me loose the SPA features of my appCurrently getInitialProps is called during
next export
, I expected this information to be used on the generated pages.The current examples on data fetching do depend on a running server, but none explains what to do if the data fetch depends on a custom next server that is only reachable during
next export
Is the only solution to use
<a>
links? Or is it possible that if I hit a route likeexample.com/about
I could still query the fetched data result that was generated during the export of that page?