mirror of https://github.com/coder/code-server.git
parent
6745a46034
commit
b3b971480f
|
@ -386,10 +386,14 @@ function getHost(req: express.Request): string | undefined {
|
|||
}
|
||||
}
|
||||
|
||||
// Honor X-Forwarded-Host if present.
|
||||
// Honor X-Forwarded-Host if present. Some reverse proxies will set multiple
|
||||
// comma-separated hosts.
|
||||
const xHost = getFirstHeader(req, "x-forwarded-host")
|
||||
if (xHost) {
|
||||
return xHost.trim().toLowerCase()
|
||||
const firstXHost = xHost.split(",")[0]
|
||||
if (firstXHost) {
|
||||
return firstXHost.trim().toLowerCase()
|
||||
}
|
||||
}
|
||||
|
||||
const host = getFirstHeader(req, "host")
|
||||
|
|
|
@ -58,6 +58,7 @@ describe("http", () => {
|
|||
;[
|
||||
["host", test.host],
|
||||
["x-forwarded-host", test.host],
|
||||
["x-forwarded-host", `${test.host}, ${test.host}`],
|
||||
["forwarded", `for=127.0.0.1, host=${test.host}, proto=http`],
|
||||
["forwarded", `for=127.0.0.1;proto=http;host=${test.host}`],
|
||||
["forwarded", `proto=http;host=${test.host}, for=127.0.0.1`],
|
||||
|
|
Loading…
Reference in New Issue