next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Calling `redirect("./")` from server action updates route to `./` but with page content from `/`

Open brhx opened this issue 1 year ago • 0 comments

Link to the code that reproduces this issue

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

To Reproduce

  1. Clone the repo and start next dev
  2. Open the path http://localhost:3000/hello/world
  3. Press the button to call the server action to navigate to ./

Current vs. Expected behavior

Calling redirect("./") in a server action on /hello/world I'd expect the following page to be /hello

image

However upon clicking I get redirected to /hello/ (with a forward slash) on the client router and the page content contains / instead of the content of /hello

image

Then if I refresh the content of /hello is loaded correctly and the trailing forward slash is stripped

image

This issue doesn't occur if JavaScript is disabled.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.0.0: Mon Aug 12 20:51:54 PDT 2024; root:xnu-11215.1.10~2/RELEASE_ARM64_T6000
  Available memory (MB): 65536
  Available CPU cores: 10
Binaries:
  Node: 20.11.1
  npm: 10.2.4
  Yarn: N/A
  pnpm: 8.15.7
Relevant Packages:
  next: 15.0.2-canary.7 // Latest available version is detected (15.0.2-canary.7).
  eslint-config-next: 15.0.1
  react: 19.0.0-rc-69d4b800-20241021
  react-dom: 19.0.0-rc-69d4b800-20241021
  typescript: 5.6.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

brhx avatar Oct 26 '24 16:10 brhx