mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
## Problem PR #23109 introduced port normalization for the private IP blocking feature, which mutated `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 `CODER_REDIRECT_TO_ACCESS_URL=true`, the `redirectToAccessURL` middleware compared the `Host` header 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: ``` Failed to start MCP client: Streamable HTTP error: Unexpected content type: text/html; charset=utf-8 Failed to load custom agents: SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON ``` ## Changes - Stop mutating `coderAccessURL.Host`; store the resolved port in a separate field for `isBlockedIP` - Update existing tests that asserted the old (mutated) `.Port()` behavior - Add test cases verifying the Host is preserved with and without an explicit port > Generated with the assistance of Coder Agents on behalf of @ssncferreira