Allow setting value of Express 'trust proxy' from config (#13034)

* Allow setting value of Express 'trust proxy' from config

* Allow config to disable 'trust proxy' if port is 80/443

And show the value of trust_proxy in log

* fix errors
This commit is contained in:
ledlamp
2025-08-27 15:42:30 -07:00
committed by GitHub
parent f5ad786240
commit 8a326a6e74

View File

@@ -277,9 +277,12 @@ async function listen() {
}
}
port = parseInt(port, 10);
if ((port !== 80 && port !== 443) || nconf.get('trust_proxy') === true) {
winston.info('🤝 Enabling \'trust proxy\'');
app.enable('trust proxy');
let trust_proxy = nconf.get('trust_proxy');
if (trust_proxy == null && ![80, 443].includes(port)) trust_proxy = true;
if (trust_proxy) {
winston.info(`🤝 Setting 'trust proxy' to ${JSON.stringify(trust_proxy)}`);
app.set('trust proxy', trust_proxy);
}
if ((port === 80 || port === 443) && process.env.NODE_ENV !== 'development') {