Preserve the original host on action redirect streams - #96977
Draft
DavidIlie wants to merge 3 commits into
Draft
Conversation
When an action POST lands on a route that does not bundle the action, it is
forwarded to a worker that does, via an internal self-fetch to
`__NEXT_PRIVATE_ORIGIN`. `host` is a forbidden `fetch` header, so it cannot be
carried onto the subrequest: the action saw `headers().get('host')` as
`localhost:PORT` instead of the host the user requested. That breaks
host-based multi-tenancy for exactly those actions that happen to get
forwarded, which depends on the build's static import graph rather than
anything visible in the application.
Restore `host` from `x-forwarded-host`, which does survive the forward,
guarded on the request being marked `x-action-forwarded` and having arrived at
the internal origin. `x-forwarded-host` is already preferred over `host` by
`parseHostHeader` for the CSRF origin check, so this aligns userland
`headers()` with the value the framework already trusts.
Fixes vercel#96344
Contributor
Tests PassedCommit: 7b82386 |
Contributor
Stats from current PR🔴 1 regression, 2 improvements
📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles
Server Middleware
Build DetailsBuild Manifests
Build Cache
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📝 Changed Files (9 files)Files with changes:
View diffsapp-page-exp..ntime.dev.jsDiff too large to display app-page-exp..time.prod.jsfailed to diffapp-page-tur..ntime.dev.jsDiff too large to display app-page-tur..time.prod.jsfailed to diffapp-page-tur..ntime.dev.jsDiff too large to display app-page-tur..time.prod.jsDiff too large to display app-page.runtime.dev.jsDiff too large to display app-page.runtime.prod.jsDiff too large to display server.runtime.prod.jsDiff too large to display 📎 Tarball URLCommit: 7b82386 |
DavidIlie
force-pushed
the
codex/redirect-render-original-host
branch
from
August 8, 2026 22:28
122e33c to
95d8334
Compare
DavidIlie
force-pushed
the
codex/redirect-render-original-host
branch
from
August 8, 2026 22:41
95d8334 to
7b82386
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
forwarded between workers.
createRedirectRenderResult, used to stream app-relative ServerAction redirects.
x-action-redirect-forwarded: 1marker.Hostfromx-forwarded-hostonly for theexact internal GET + RSC request shape.
subsequently redirect.
Why
Hostbecomes something likelocalhost:PORT.headers().get('host')in the redirect target seesthe internal host instead of the public tenant host.
naturally set
x-action-forwarded.Security details
1;Hostmatching the internal forwarding origin;Verification
pnpm build-allpassed.