From 077fc48501e5aeaa9f51978a3040bfc6878c8101 Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Thu, 8 Dec 2022 18:41:15 +0300 Subject: [PATCH] [feature] Allow CloudFront-Forwarded-Proto header --- Common/sources/utils.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Common/sources/utils.js b/Common/sources/utils.js index e510fa8d..6fc7edbe 100644 --- a/Common/sources/utils.js +++ b/Common/sources/utils.js @@ -685,10 +685,12 @@ function getBaseUrl(protocol, hostHeader, forwardedProtoHeader, forwardedHostHea } function getBaseUrlByConnection(conn) { conn = conn.request; - return getBaseUrl('', conn.headers['host'], conn.headers['x-forwarded-proto'], conn.headers['x-forwarded-host'], conn.headers['x-forwarded-prefix']); + let proto = conn.headers['x-forwarded-proto'] || conn.headers['cloudfront-forwarded-proto']; + return getBaseUrl('', conn.headers['host'], proto, conn.headers['x-forwarded-host'], conn.headers['x-forwarded-prefix']); } function getBaseUrlByRequest(req) { - return getBaseUrl(req.protocol, req.get('host'), req.get('x-forwarded-proto'), req.get('x-forwarded-host'), req.get('x-forwarded-prefix')); + let proto = req.get('x-forwarded-proto') || req.get('cloudfront-forwarded-proto'); + return getBaseUrl(req.protocol, req.get('host'), proto, req.get('x-forwarded-host'), req.get('x-forwarded-prefix')); } exports.getBaseUrlByConnection = getBaseUrlByConnection; exports.getBaseUrlByRequest = getBaseUrlByRequest;