Skip to content

Commit

Permalink
Trust proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
kucingbasah737 committed Nov 25, 2023
1 parent d9720c0 commit 829c2d6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/webserver/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const logger = require('../logger');
const targetLookup = require('./target-lookup');

const listenPort = Number(process.env.WEB_PORT) || 8080;
const trustProxy = process.env.WEB_TRUST_PROXY
&& process.env.WEB_TRUST_PROXY.split(/\s*,\s*/);

module.exports = () => {
if (!listenPort) {
Expand All @@ -15,6 +17,13 @@ module.exports = () => {

const app = express();

if (trustProxy) {
logger.verbose(`${MODULE_NAME} 1DFD2897: Trusting proxies`, {
trustProxy,
});
app.set('trust proxy', trustProxy);
}

app.use((req, res, next) => {
res.locals.xid = uniqid();
next();
Expand Down

0 comments on commit 829c2d6

Please sign in to comment.