fix(enterprise/aibridgeproxyd): stop injecting default port into forwarded Host header#26656
Merged
Merged
Conversation
b4cceb4 to
863884a
Compare
…arded Host header The proxy normalized CoderAccessURL.Host to always include the default port (e.g. coder.example.com:443). This leaked into the Host header of every request forwarded to the Coder server. When redirectToAccessURL was enabled, the middleware compared the Host header against the access URL literally, saw a mismatch, and redirected to the SPA root. Copilot then received HTML instead of JSON: Failed to load custom agents: SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON Store the resolved port in a separate field for isBlockedIP and stop mutating coderAccessURL.Host.
863884a to
12aeb84
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
PR #23109 introduced port normalization for the private IP blocking feature, which mutated
CoderAccessURL.Hostto always include the default port (e.g.coder.example.com:443). This leaked into theHostheader of every request forwarded to the Coder server.When
CODER_REDIRECT_TO_ACCESS_URL=true, theredirectToAccessURLmiddleware compared theHostheader literally against the access URL (coder.example.com), saw a mismatch, and returned a 307 redirect to the Coder dashboard HTML page.Copilot then received HTML instead of JSON:
Changes
coderAccessURL.Host; store the resolved port in a separate field forisBlockedIP.Port()behavior