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

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

Open
sam3d opened this issue Oct 26, 2024 · 0 comments · May be fixed by #71932
Open

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

sam3d opened this issue Oct 26, 2024 · 0 comments · May be fixed by #71932
Labels
bug Issue was opened via the bug report template. Navigation Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@sam3d
Copy link
Contributor

sam3d commented Oct 26, 2024

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

@sam3d sam3d added the bug Issue was opened via the bug report template. label Oct 26, 2024
@github-actions github-actions bot added the Navigation Related to Next.js linking (e.g., <Link>) and navigation. label Oct 26, 2024
@sam3d sam3d changed the title Redirecting to ./ in a server action correctly sets client route to ./ but updates page content to root Calling redirect("./") from server action updates route to ./ but loads page content from / Oct 26, 2024
@sam3d sam3d changed the title Calling redirect("./") from server action updates route to ./ but loads page content from / Calling redirect("./") from server action updates route to ./ but with page content from / Oct 26, 2024
@vordgi vordgi linked a pull request Oct 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Navigation Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant