Use x-forwarded-host when evaluating the remote authority (#152871)

Use x-forwarded-host
This commit is contained in:
Martin Aeschlimann
2022-06-23 08:58:07 +02:00
committed by GitHub
parent 87a6ba590a
commit 315bccd0b1
+6 -5
View File
@@ -267,11 +267,12 @@ export class WebClientServer {
return res.end();
}
let originalHost = req.headers['x-original-host'];
if (Array.isArray(originalHost)) {
originalHost = originalHost[0];
}
const remoteAuthority = originalHost || req.headers.host;
const getFirstHeader = (headerName: string) => {
const val = req.headers[headerName];
return Array.isArray(val) ? val[0] : val;
};
const remoteAuthority = getFirstHeader('x-original-host') || getFirstHeader('x-forwarded-host') || req.headers.host;
if (!remoteAuthority) {
return serveError(req, res, 400, `Bad request.`);
}