Repository navigation
Conversation
Prevent redirects from forwarding caller Authorization and Cookie headers to a different origin, including constructor defaults. Keep destination jar cookies and defaults for independent fetches.
This branch has not been deployed
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.
Summary
The JavaScript redirect loop reuses request headers for every hop. Native constructor defaults can also reappear when the redirect request omits those headers. This forwards caller-supplied
Authorizationand rawCookieheaders to another origin.Track whether the fetch has crossed an origin, filter those two request headers case-insensitively, and shadow native defaults using the existing empty-value omission semantics. Keep cookie-jar lookup/persistence per hop and do not mutate the caller's header arrays or instance defaults. No Rust, dependency, API, or release/version changes.
Evidence
pnpm exec vitest run test/redirect-credentials.test.ts test/cookies.test.ts --retry=0— 24 passed (3 new regressions + 21 existing cookie tests).pnpm exec tsc --noEmit --module nodenext --moduleResolution nodenext --target es2022 --skipLibCheck --types node test/redirect-credentials.test.ts.git diff --checkpasses. Full Rust rebuild, remote fingerprint/e2e tests and other platforms were not run locally.Merge Danger
Door: two-way; JavaScript wrapper change only.
Blast Radius: redirects.
Callers relying on cross-origin forwarding of explicit/default credentials will observe stricter behavior. Destination-scoped jar cookies still work; same-origin redirects and fresh independent fetches retain their existing credentials. Empty suppression values are consumed by the native header builder, not sent as empty HTTP headers.