Repository navigation
Proxy domains when the host includes a port - #8129
Open
adityajai119 wants to merge 1 commit into
Open
adityajai119 wants to merge 1 commit into
adityajai119 wants to merge 1 commit into
Conversation
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.
Fixes #8128
Since #6225 (4.14.0),
maybeProxy()matches the host fromgetHost(), which keeps the port, against a proxy domain pattern anchored at the end, such as^(\d+)\.example\.com$. Before that it dropped the port from the host first, andgetCookieDomain()still does. So with--proxy-domain example.com, a request to3000.example.com:8080, or one forwarded withX-Forwarded-Host: 3000.example.com:443, is not proxied and code-server serves itself instead. #7194 ran into this and worked around it by adding the port to the proxy domain.This lets the pattern match an optional
:portat the end of the host. Proxy domains that already include a port, such asexample.com:12345, keep matching as before.Testing, on Windows 11 with Node 24.22.1:
test/unit/node/proxy.test.ts: with--proxy-domain=example.com, a request with the host<port>.example.comand one with<port>.example.com:8443both reach the app. Onmainthe second one fails (500 from code-server's own routes instead of the proxied 200), and it passes with this change.test/unit/node/proxy.test.ts: 21 passed.test/unit/node/http.test.ts: 138 passed.npx tsc --noEmit -p tsconfig.json, ESLint and Prettier on the changed files.AI-assisted: drafted with an AI coding agent; the tests above were run locally.