next.js: `dynamicParams=false` show 404 page in dev, but not show 404 page after build in prod
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #22 SMP Tue Jan 10 18:39:00 UTC 2023
Binaries:
Node: 16.17.0
npm: 8.15.0
Yarn: 1.22.19
pnpm: 7.1.0
Relevant Packages:
next: 13.4.10-canary.8
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
typescript: 4.9.5
Next.js Config:
output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
App Router
Link to the code that reproduces this issue or a replay of the bug
https://codesandbox.io/p/sandbox/wandering-forest-3tmmtz
To Reproduce
Run yarn dev, then access https://3tmmtz-3000.csb.app/post/404, it shows 404 page which is expected.
Run yarn build, then yarn start in prod mode, access the same url as above, it shows the rendering page, not 404 page.
Describe the Bug
Leaving dynamicParams=false and accessing an entry point that does not exist in generateStaticParams does not return a 404 page in prod. (dev works fine)
The generateStaticParams only returns id 1,2,3 which means all the other param with id should return 404. Seems dev works as expected but prod is not.
Expected Behavior
when access a param that not returned by generateStaticParams function, it should return 404 page in both dev and prod.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 11
- Comments: 18 (4 by maintainers)
Commits related to this issue
- WEB-9: Fix 404 page not displaying correctly This was fixed by using a workaround from the following NextJS issue: https://github.com/vercel/next.js/issues/52765 — committed to GriffinBaxter/GriffinBaxter.com by GriffinBaxter 3 years ago
- fix: disable dynamicParams = false possibly a bug in Next.js causing everything to 404 if dynamicParams = false https://github.com/vercel/next.js/issues/52765 — committed to Testausserveri/testausserveri.fi by ahnl 2 years ago
I am using fetch without {next: { revalidate: 0 },} and still have the same issue in Next 14.2.3.
Also facing the same problem with 14.2.3. I’m trying to limit our website to specific languages (example.com/en and example.com/fr), but I can’t get it to consistently throw a 404 for random values.
Also facing the same problem as of today.
For me the problem is with Vercel. I have the exact same project on Vercel and Netlify. Netlify returns 404 as expected, Vercel doesn’t. The same code on Vercel: https://keytours-test.vercel.app/en/meteora/shoud-not-work and Netlify: https://keytours-test.netlify.app/en/meteora/shoud-not-work