mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-06 23:06:20 +01:00
Use x-forwarded-host when evaluating the remote authority (#152871)
Use x-forwarded-host
This commit is contained in:
committed by
GitHub
parent
87a6ba590a
commit
315bccd0b1
@@ -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.`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user