Closed nickrobillard closed 7 years ago
Ok this is my bad. I should have been using npm run start
or yarn start
to start the prod server. Issue resolved.
@nickrobillard How did you solve it? I'm facing the same error on production only, 404 for sub-pages as well if I enter directly, but not if using <Link>
.
In Step 2, replace npm start
with npm run start
or yarn start
. npm start
starts the server with default next config, which is wrong because this example uses a custom server. Credit goes to @grokling on slack for catching this.
Oh got it!! Do we need to run our own server (node server.js
) instead of the next.js one (next start
) right?
It's working now 😄 thanks!
Yes, you can see this in the example's package.json
. The build
script runs NODE_ENV=production node server.js
.
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
When I test a prod build (
next build
andnext 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:
next build
followed bynext start
Blog: Hello world
I'm assuming this was working at some point. Maybe this was introduced in Next.js v3?