Skip to content

Commit 315bccd

Browse files
authored
Use x-forwarded-host when evaluating the remote authority (microsoft#152871)
Use x-forwarded-host
1 parent 87a6ba5 commit 315bccd

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/vs/server/node/webClientServer.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,12 @@ export class WebClientServer {
267267
return res.end();
268268
}
269269

270-
let originalHost = req.headers['x-original-host'];
271-
if (Array.isArray(originalHost)) {
272-
originalHost = originalHost[0];
273-
}
274-
const remoteAuthority = originalHost || req.headers.host;
270+
const getFirstHeader = (headerName: string) => {
271+
const val = req.headers[headerName];
272+
return Array.isArray(val) ? val[0] : val;
273+
};
274+
275+
const remoteAuthority = getFirstHeader('x-original-host') || getFirstHeader('x-forwarded-host') || req.headers.host;
275276
if (!remoteAuthority) {
276277
return serveError(req, res, 400, `Bad request.`);
277278
}

0 commit comments

Comments
 (0)