Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/node/routes/domainProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = []
Expand Down
13 changes: 13 additions & 0 deletions test/unit/node/proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
Loading