From 712905261875036a7cf4ea68ea28cd74f636cfcf Mon Sep 17 00:00:00 2001 From: adityajai119 Date: Fri, 13 Nov 2026 10:25:20 +0530 Subject: [PATCH] Proxy domains when the host includes a port Fixes #8128 --- src/node/routes/domainProxy.ts | 2 +- test/unit/node/proxy.test.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/node/routes/domainProxy.ts b/src/node/routes/domainProxy.ts index 6ffee67fa002..68f01ef2decd 100644 --- a/src/node/routes/domainProxy.ts +++ b/src/node/routes/domainProxy.ts @@ -16,7 +16,7 @@ const proxyDomainToRegex = (matchString: string): RegExp => { regexString = regexString.replace(/[{}]/g, "\\$&") //replace any '{}' that might be left - return new RegExp("^" + regexString + "$") + return new RegExp("^" + regexString + "(?::\\d+)?$") } let proxyRegexes: RegExp[] = [] diff --git a/test/unit/node/proxy.test.ts b/test/unit/node/proxy.test.ts index b1cf90612a2e..8a1b1d6406f0 100644 --- a/test/unit/node/proxy.test.ts +++ b/test/unit/node/proxy.test.ts @@ -285,6 +285,19 @@ describe("proxy", () => { expect(text).toBe("app being served behind a prefixed path") }) + it("should proxy a domain when the host has a port", async () => { + e.get("/wsup", (req, res) => { + res.json("asher is the best") + }) + codeServer = await integration.setup(["--auth=none", "--proxy-domain=example.com"], "") + let resp = await codeServer.fetch("/wsup", { headers: { host: `${proxyTarget.port()}.example.com` } }) + expect(resp.status).toBe(200) + expect(await resp.json()).toBe("asher is the best") + resp = await codeServer.fetch("/wsup", { headers: { host: `${proxyTarget.port()}.example.com:8443` } }) + expect(resp.status).toBe(200) + expect(await resp.json()).toBe("asher is the best") + }) + it("should not allow OPTIONS without authentication by default", async () => { process.env.PASSWORD = "test" codeServer = await integration.setup(["--auth=password"])