Build and dev behave differently when generating static route parameters #54730
Labels
bug
Issue was opened via the bug report template.
Navigation
Related to Next.js linking (e.g., <Link>) and navigation.
SWC
Related to minification/transpilation in Next.js.
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 19.6.0: Tue Jun 21 21:18:39 PDT 2022; root:xnu-6153.141.66~1/RELEASE_X86_64 Binaries: Node: 19.3.0 npm: 9.4.2 Yarn: N/A pnpm: N/A Relevant Packages: next: 13.4.20-canary.12 eslint-config-next: 13.4.12 react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.6 Next.js Config: output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
App Router, Routing (next/router, next/navigation, next/link), SWC transpilation
Link to the code that reproduces this issue or a replay of the bug
https://github.com/ardunster/nextjs-ssr
To Reproduce
d213ec287625328019c261328fa6ce435779797a
.next dev
or its aliasnpm run dev
. Everything works.next build
or its aliasnpm run build
. Get error:Describe the Bug
The
next dev
andnext build
operations do not handle passing the static route generation to the component in the same way.next dev
passes the route strings with/
included,next build
passes them transformed to%2F
, causing the file paths to not work.I believe the fix implemented in commit
1d4177fb74acc20360311c7f5ffe6f747587c8fd
(splitting the string bypath.sep
instead of using the encoded/
characters, and recombining the segments in the file retrieval code) is more accurate to how thegenerateStaticParams
path is supposed to work, and is a better pattern to use, so the fact thatnext build
fails here is not necessarily a bug; however,next dev
working fine mislead me into thinking I had already solved a problem that I had not completely solved yet.This stackoverflow question may also be related (answer is mine).
Expected Behavior
next dev
should fail on any build step thatnext build
fails on.Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: