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

Server action redirect with absolute internal URL duplicates basePath #64557

Closed
sk-1982 opened this issue Apr 16, 2024 · 1 comment · Fixed by #64604
Closed

Server action redirect with absolute internal URL duplicates basePath #64557

sk-1982 opened this issue Apr 16, 2024 · 1 comment · Fixed by #64604
Labels
bug Issue was opened via the bug report template. locked Navigation Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@sk-1982
Copy link

sk-1982 commented Apr 16, 2024

Link to the code that reproduces this issue

https://github.com/sk-1982/nextjs-absolute-url-redirect-basepath-bug

To Reproduce

  1. Clone and start the app
  2. Visit localhost:3000/web
  3. Click the "Absolute URL Redirect" button

Current vs. Expected behavior

Current: Clicking the "Absolute URL Redirect" button sends the user to a 404 page. Reloading the page shows the correct test page. This is because #60798 made redirects with absolute internal URLs identical to relative URLs. However, this does not consider that the absolute URL will contain basePath. As a result, the redirect is equivalent to redirect('/web/test'), which resolves to http://localhost:3000/web/web/test (which doesn't exist).

Expected: redirects with an absolute internal URL should remove the base path and correctly redirect.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
  Available memory (MB): 32680
  Available CPU cores: 24
Binaries:
  Node: 21.1.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.3.0-canary.4 // Latest available version is detected (14.3.0-canary.4).
  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) are affected? (Select all that apply)

Routing (next/router, next/navigation, next/link)

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

next dev (local), next start (local), Vercel (Deployed), Other (Deployed)

Additional context

Also see related issue: #64413

@sk-1982 sk-1982 added the bug Issue was opened via the bug report template. label Apr 16, 2024
@github-actions github-actions bot added the Navigation Related to Next.js linking (e.g., <Link>) and navigation. label Apr 16, 2024
@sk-1982 sk-1982 changed the title Server action redirect with absolute internal URL ignores basePath Server action redirect with absolute internal URL duplicates basePath Apr 17, 2024
@ijjk ijjk closed this as completed in 44aeb08 Jun 18, 2024
Copy link
Contributor

github-actions bot commented Jul 3, 2024

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 added the locked label Jul 3, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 3, 2024
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

Successfully merging a pull request may close this issue.

1 participant