vercel / vercel/next.js

Pre-hydration redirect from server actions does not prepend base path

Open
#85,462 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Redirects Runtime Server Actions
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked nextjs-bad-redirect-repro and run pnpm dev with JavaScript disabled, then submit the form before hydration. Trace the Next.js server action redirect handling for the 303 response. Done means the redirect location includes /custom, leading to /custom/success and the “OK” message instead of a 404.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nextjs, playwright, react
Domain
backend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.