feat: forward client request headers to upstream providers in bridge routes#195
Open
ssncferreira wants to merge 2 commits intomainfrom
Open
feat: forward client request headers to upstream providers in bridge routes#195ssncferreira wants to merge 2 commits intomainfrom
ssncferreira wants to merge 2 commits intomainfrom
Conversation
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
4544e46 to
8c0c002
Compare
8c0c002 to
78cdc43
Compare
78cdc43 to
2a43c3e
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.

Description
AI Bridge drops client request headers when making upstream API calls through bridge routes. The interceptors construct new HTTP requests via provider SDKs, which set their own headers and discard the originals.
Rather than managing specific headers per provider (as done with Copilot's ExtraHeaders), this PR forwards all client headers to upstream providers, stripping only those that are unsafe or managed by the SDK.
Changes
intercept/client_headers.gowithSanitizeClientHeadersthat clones client headers and strips hop-by-hop and transport-managed headers before forwarding.Follow-up
The following changes will be addressed in follow-up PRs to reduce scope:
X-Forwarded-For,X-Forwarded-Host,X-Forwarded-Proto), while bridge routes do not. Since AI Bridge behaves as a proxy, this handling should be consistent across all requests.ExtraHeadersmechanism introduced for Copilot redundant, as all client headers are now forwarded. It can be safely removed.ExtraHeadersmechanism introduced for Anthropic in #205 redundant, as all client headers are now forwarded. It can be safely removed.Closes: #192