vercel / next.js

The React Framework
https://nextjs.org
MIT License
127.04k stars 27k forks source link

redirect does not work when using multiple root layouts #72352

Open llipengda opened 1 week ago

llipengda commented 1 week ago

Link to the code that reproduces this issue

https://github.com/llipengda/next-redirect-bug

To Reproduce

  1. next dev
  2. click /test-a
  3. click redirect to /
  4. the page is navigated to /
  5. click /test-b
  6. click redirect to /
  7. this does not work

Current vs. Expected behavior

current: when clicking redirect to / in /test-b, redirect does not work. expected: redirect to /

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Home China
  Available memory (MB): 16164
  Available CPU cores: 16
Binaries:
  Node: 20.18.0
  npm: 10.8.3
  Yarn: 1.22.22
  pnpm: 9.12.2
Relevant Packages:
  next: 15.0.3-canary.6 // Latest available version is detected (15.0.3-canary.6).
  eslint-config-next: N/A
  react: 19.0.0-rc-7c8e5e7a-20241101
  react-dom: 19.0.0-rc-7c8e5e7a-20241101
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Navigation

Which stage(s) are affected? (Select all that apply)

next dev (local), next start (local)

Additional context

No response

llipengda commented 1 week ago

Is this a bug, or was it designed to be this way? I deployed it on Vercel next-redirect-bug-gamma.vercel.app Can someone help me?