Repository navigation
Conversation
fetchWithAuth and the axios clients set no redirect handling, so a redirect to another origin was followed with the custom credential headers still on the request: fetch and follow-redirects only drop Authorization. Redirects are still followed. On a hop to another origin the request goes on without Authorization, on-behalf-of, Base44-Service-Authorization and Base44-State. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018bQbJdizPXhMxLN3cpSWj4
Contributor
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/sdk@0.8.64-pr.398.d867f81Prefer not to change any import paths? Install using npm alias so your code still imports npm i "@base44/sdk@npm:@base44-preview/sdk@0.8.64-pr.398.d867f81"Or add it to your {
"dependencies": {
"@base44/sdk": "npm:@base44-preview/sdk@0.8.64-pr.398.d867f81"
}
}
Preview published to npm registry — try new features instantly! |
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.
What
Credentialed requests from the SDK set no redirect handling. When a redirect leads to another origin, the HTTP client follows it and only drops
Authorization; the SDK's custom credential headers stay on the request.This PR keeps following redirects and removes the credentials on a hop to another origin.
fetchWithAuth: when the request carries a server credential (Base44-Service-AuthorizationorBase44-State), the SDK follows redirects itself. A hop to another origin goes withoutAuthorization,Base44-Service-AuthorizationandBase44-State. They are not restored if a later hop returns to the app.sensitiveHeaders(axios ≥ 1.20, already our minimum) listsAuthorization,on-behalf-of,Base44-Service-AuthorizationandBase44-State. axios drops them on a redirect to another origin and keeps them on a same-origin one.Why not
redirect: "manual"/maxRedirects: 0Turning redirect following off is the usual fix, and it is shorter. It also changes behaviour for every app whose route or API call redirects today:
manual/maxRedirects: 0)manualreturns an opaque response that cannot be followedSo the only code that behaves differently is code that depended on the tokens arriving at another origin.
Other cases that stay as they are:
redirectininitkeeps full control; the SDK does not step in.fetch) returns the 3xx without aurland never followed redirects. The SDK returns that response as it is.Differences from native
fetchon the guarded pathresponse.redirectedisfalseon the final response, since each hop is its own request.response.urlis still the final URL.fetchdoes, with the SDK's own message.Verification
tests/unit/redirect-credentials.test.tsruns realfetchand axios against two local HTTP servers. Three of its tests fail onmainand pass here; the rest pin the behaviour that must not change (same-origin, 303/307 method rules, in-process transport, caller-setredirect).create-docsgenerates.Base44-Service-Authorizationto the other origin;Authorization, and a same-origin redirect still receives both;redirect: "manual"returns the real 3xx withurlset, which the guard relies on.Not covered
sensitiveHeaders. On Workers axios uses the Node http adapter, where a redirect currently fails before any second request is sent, so nothing leaves there either way.🤖 Generated with Claude Code
https://claude.ai/code/session_018bQbJdizPXhMxLN3cpSWj4