Skip to content

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

@greenlynx

Description

@greenlynx

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    RedirectsRelated to redirecting.RuntimeRelated to Node.js or Edge Runtime with Next.js.Server ActionsRelated to Server Actions.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions