question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

On static export, links fail but reload works

See original GitHub issue

When 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:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
timneutkenscommented, Mar 9, 2019
1reaction
fgarciacommented, May 15, 2018

After working around this issue I noticed that <Link> causes getInitialProps 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 app

Currently 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 like example.com/about I could still query the fetched data result that was generated during the export of that page?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found