Competing catch-all routes break client-side navigation in dev mode #54376
Labels
bug
Issue was opened via the bug report template.
locked
Navigation
Related to Next.js linking (e.g., <Link>) and navigation.
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023 Binaries: Node: 16.17.0 npm: 8.15.0 Yarn: 1.22.19 pnpm: 7.1.0 Relevant Packages: next: 13.4.20-canary.1 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.3 Next.js Config: output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
Routing (next/router, next/navigation, next/link)
Link to the code that reproduces this issue or a replay of the bug
https://codesandbox.io/p/sandbox/friendly-antonelli-xpmzl4?file=/pages/index.tsx
To Reproduce
a. HTML link (<a href=>) shows intended behavior
b. next/link component shows bug behavior
Please note, that the bug behavior only appears in dev mode (
npm run dev
).Describe the Bug
We have two routes,
/somepath/[id]/
and/[...slug]
. The former is used to access server-side rendered pages for a collection of resources, the latter is a catch-all route with getStaticPaths (to render some pages from a CMS) and some custom 404 logic.Since updating to
[email protected]
, we're now seeing an erroneous behavior in dev mode when using client-side navigation to paths like/somepath/foo
. Instead of the correct page, we see the 404 logic of the/[...slug]
-catch-all page being executed and leading to rendering the 404. This behavior is not exhibited when runningnext build && next start
.The issue occurrs only if
/somepath/[id]/
usesgetServerSideProps
and if/[...slug]
'sgetStaticProps
returns{ notFound: true }
. This could mean there is some kind of mismatch in howgetStaticPaths
is handled in the dev- and production-server respectively. Maybe this is related to 1398de9 (which is part of the breaking patch release 13.4.13)?Expected Behavior
Navigation should work as expected in dev mode.
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: