feat: add support for X-Forwarded-Path in style urls (#1239)
* add support for X-Forwarded-Path for styles too * fix linting issue
This commit is contained in:
parent
71dc40c2ce
commit
6742c7f45d
1 changed files with 6 additions and 0 deletions
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue