feat: add support for x-forward-port header (#1423)

* feat: add support for x-forward-port header

* fix: remove unnecessary port additions

* chore: remove unused dependency
This commit is contained in:
daniel-milemarker 2025-01-02 12:29:53 -07:00 committed by GitHub
parent a2bc9f0cce
commit 9d222c1dec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -50,6 +50,12 @@ const getUrlObject = (req) => {
// support overriding hostname by sending X-Forwarded-Host http header // support overriding hostname by sending X-Forwarded-Host http header
urlObject.hostname = req.hostname; urlObject.hostname = req.hostname;
// support overriding port by sending X-Forwarded-Port http header
const xForwardedPort = req.get('X-Forwarded-Port');
if (xForwardedPort) {
urlObject.port = xForwardedPort;
}
// support add url prefix by sending X-Forwarded-Path http header // support add url prefix by sending X-Forwarded-Path http header
const xForwardedPath = req.get('X-Forwarded-Path'); const xForwardedPath = req.get('X-Forwarded-Path');
if (xForwardedPath) { if (xForwardedPath) {