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.

In prod build, all pages (except /) return 404 when server rendered

See original GitHub issue

When I test a prod build (next build and next start), server generated sub-pages return 404. This is reproducible with the next-routes example in the next repo - https://github.com/zeit/next.js/tree/master/examples/with-next-routes.

Steps to reproduce:

  1. Follow installation instructions (https://github.com/zeit/next.js/tree/master/examples/with-next-routes)
  2. Run commands next build followed by next start
  3. Navigate to the first link Blog: Hello world
  4. Refresh page and observe 404

I’m assuming this was working at some point. Maybe this was introduced in Next.js v3?

screen shot 2017-09-12 at 8 49 30 pm

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
nickrobillardcommented, Sep 18, 2017

Yes, you can see this in the example’s package.json. The build script runs NODE_ENV=production node server.js.

0reactions
andrewmartincommented, Jul 13, 2020

Oh man, thank you so much. Was wrangling with this one for a minute and driving myself nuts…Realized I had a wonky ecosystem.config.js using npm run start instead of yarn start

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next.js pages end in 404 on production build - Stack Overflow
The pages works fine in development env, but if I try to run the production build only the index.js page is loaded properly,...
Read more >
How To Properly Serve 404 Errors on SPAs (with SEO in Mind)
Out of the box, 404 error pages in SPAs don't work properly, creating problems for SEO. Here we'll review the pros and cons...
Read more >
Nginx: All Pages Return 404 Not Found except Home Page
I'm using Magento 2.4.4 , I've set up the existing project, but all page goes to 404 except the homepage. I'm using Nginx...
Read more >
Fixing the 'cannot GET /URL' error on refresh with React ...
In this post you'll learn how to fix the 'cannot GET /URL' error with React Router. Along the way, you'll also learn how...
Read more >
Dynamic Routes Details - Next.js
The paths returned from getStaticPaths will be rendered to HTML at build time. ... that have not been generated at build time will...
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