Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Competing catch-all routes break client-side navigation in dev mode #54376

Closed
1 task done
Parnswir opened this issue Aug 22, 2023 · 5 comments
Closed
1 task done

Competing catch-all routes break client-side navigation in dev mode #54376

Parnswir opened this issue Aug 22, 2023 · 5 comments
Labels
bug Issue was opened via the bug report template. locked Navigation Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@Parnswir
Copy link
Contributor

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: #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

  1. Open CodeSandbox
  2. In dev mode: click on links on index page
    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 running next build && next start.

The issue occurrs only if /somepath/[id]/ uses getServerSideProps and if /[...slug]'s getStaticProps returns { notFound: true }. This could mean there is some kind of mismatch in how getStaticPaths 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

@Parnswir Parnswir added the bug Issue was opened via the bug report template. label Aug 22, 2023
@github-actions github-actions bot added the Navigation Related to Next.js linking (e.g., <Link>) and navigation. label Aug 22, 2023
@samipshah100
Copy link

I am having the same issue.

@marcinincreo
Copy link

Same issue for me. This prevents us from further updating all NextJS solutions.

@marcinincreo
Copy link

@Parnswir I've checked the 13.4.20-canary.9 version and it seems that the issue is not there anymore.

@timneutkens
Copy link
Member

This was fixed in #54364

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked Navigation Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
Development

No branches or pull requests

4 participants