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

redirect to url with a different base path in server action does not work #65257

Open
levinqdl opened this issue May 2, 2024 · 0 comments · May be fixed by #65375
Open

redirect to url with a different base path in server action does not work #65257

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

Comments

@levinqdl
Copy link

levinqdl commented May 2, 2024

Link to the code that reproduces this issue

https://github.com/levinqdl/reproduction-app

Config the app with base path /app.
To demonstrate the issue, a rewrite from /external to https://example.vercel.sh is added, in production, it should be another app with the same origin and a different base path.

To Reproduce

  1. Start the app in development (next dev)
  2. Visit http://localhost:3000/app
  3. Click redirect

Current vs. Expected behavior

Expect:

the page is redirected to bing.com

Current:

  1. the route changes to http:/localhost:3000/external, and the page got a 404 error page from next.js
  2. if I refresh browser on the 404 page, contents of https://example.vercel.sh is shown

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 20.11.1
  npm: 10.2.4
  Yarn: 1.22.19
  pnpm: 9.0.6
Relevant Packages:
  next: 14.3.0-canary.36 // Latest available version is detected (14.3.0-canary.36).
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.1.3
Next.js Config:
  output: N/A

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

Navigation, server action, base path

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

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

Additional context

The issue breaks navigation from apps routed by different base paths, such as OAuth flow. I think it's because Next.js perform redirects to same origin of the app as a client side navigation, not considering the base path.

@levinqdl levinqdl added the bug Issue was opened via the bug report template. label May 2, 2024
@github-actions github-actions bot added the Navigation Related to Next.js linking (e.g., <Link>) and navigation. label May 2, 2024
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