add support for X-Forwarded-Path for styles too

This commit is contained in:
v-electrolux 2024-04-25 17:33:19 +03:00 committed by Andrew Calcutt
parent 71dc40c2ce
commit ef7137b763

View file

@ -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;
};