nextjs - ✅(Solved) Fix Pre-hydration redirect from server actions does not prepend base path [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#85462Fetched 2026-04-08 02:15:36
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
1
Author
Participants
Timeline (top)
labeled ×3cross-referenced ×1issue_type_added ×1subscribed ×1

Error Message

  • Redirect to /success and see a 404 error (because the base path /custom was not prepended to the redirect location)

Root Cause

  • Redirect to /success and see a 404 error (because the base path /custom was not prepended to the redirect location)

Fix Action

Fixed

PR fix notes

PR #86684: Fix 'Pre-hydration redirect from server actions does not prepend base…

Description (problem / solution / changelog)

Fixes #85462

Changed files

  • packages/next/src/server/app-render/action-handler.ts (modified, +11/-1)

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 14
Binaries:
  Node: 22.20.0
  npm: 10.9.3
  Yarn: 1.22.22
  pnpm: 10.18.3
Relevant Packages:
  next: 16.0.1-canary.5 // Latest available version is detected (16.0.1-canary.5).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/greenlynx/nextjs-bad-redirect-repro

To Reproduce

Our application has a base path set, and a form that submits to a server action that causes a redirect. When the app is tested using Playwright, and the form is submitted before the page is hydrated, the redirect location in the 303 response is wrong (it is missing the base path).

Steps to reproduce

  1. Disable Javascript in browser
  2. pnpm dev
  3. Click submit button

Current vs. Expected behavior

Current behaviour

  • Redirect to /success and see a 404 error (because the base path /custom was not prepended to the redirect location)

Expected behaviour

  • Redirect to /custom/success, and see "OK" message

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 14
Binaries:
  Node: 22.20.0
  npm: 10.9.3
  Yarn: 1.22.22
  pnpm: 10.18.3
Relevant Packages:
  next: 16.0.1-canary.5 // Latest available version is detected (16.0.1-canary.5).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

Redirects, Server Actions, Runtime

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

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

Additional context

No response

extent analysis

TL;DR

The issue can be fixed by ensuring the base path is correctly prepended to the redirect location when the form is submitted before the page is hydrated.

Guidance

  • Verify that the basePath is correctly set in the Next.js configuration and that it is being used when generating the redirect URL.
  • Check the server action code to ensure it is correctly handling the base path when generating the redirect response.
  • Test the application with JavaScript enabled to see if the issue is specific to the case where the page is not hydrated.
  • Review the Playwright test to ensure it is correctly simulating the form submission and verifying the redirect location.

Example

No code example is provided as the issue is more related to the configuration and server action code, which is not shown in the provided information.

Notes

The issue seems to be related to how Next.js handles redirects when the page is not hydrated, and the base path is not being correctly prepended to the redirect location. The provided information does not include the server action code or the Next.js configuration, which are crucial in identifying the root cause of the issue.

Recommendation

Apply workaround: Modify the server action code to manually prepend the base path to the redirect location when the page is not hydrated, to ensure the correct redirect URL is generated.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - ✅(Solved) Fix Pre-hydration redirect from server actions does not prepend base path [1 pull requests, 1 participants]