From ef7137b7637f2ed3ff8b906a5a2c804668600191 Mon Sep 17 00:00:00 2001 From: v-electrolux Date: Thu, 25 Apr 2024 17:33:19 +0300 Subject: [PATCH] add support for X-Forwarded-Path for styles too --- src/utils.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils.js b/src/utils.js index 58c8f5e..670420e 100644 --- a/src/utils.js +++ b/src/utils.js @@ -48,6 +48,12 @@ const getUrlObject = (req) => { const urlObject = new URL(`${req.protocol}://${req.headers.host}/`); // support overriding hostname by sending X-Forwarded-Host http header urlObject.hostname = req.hostname; + + // support add url prefix by sending X-Forwarded-Path http header + const xForwardedPath = req.get('X-Forwarded-Path'); + if (xForwardedPath) { + urlObject.pathname = path.posix.join(xForwardedPath, urlObject.pathname); + } return urlObject; };