File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,6 +91,11 @@ let defaultConfig = {
9191 publicUrl :
9292 'This will be overriden by environment variable SERVER_PUBLIC_URL' ,
9393 } ,
94+ trustProxy : {
95+ enabled : false ,
96+ // see https://expressjs.com/en/guide/behind-proxies.html
97+ value : 0 ,
98+ } ,
9499} ;
95100
96101module . exports = defaultConfig ;
Original file line number Diff line number Diff line change @@ -62,6 +62,11 @@ let prodConfig = {
6262 } ,
6363 ] ,
6464 } ,
65+ trustProxy : {
66+ enabled : true ,
67+ // see https://expressjs.com/en/guide/behind-proxies.html
68+ value : 1 ,
69+ } ,
6570} ;
6671
6772prodConfig = _ . merge ( { } , defaultConfig , prodConfig ) ;
Original file line number Diff line number Diff line change @@ -221,6 +221,11 @@ let testConfig = {
221221 } ,
222222 ] ,
223223 } ,
224+ trustProxy : {
225+ enabled : false ,
226+ // see https://expressjs.com/en/guide/behind-proxies.html
227+ value : 0 ,
228+ } ,
224229} ;
225230
226231testConfig = _ . merge ( { } , defaultConfig , testConfig ) ;
Original file line number Diff line number Diff line change @@ -14,10 +14,8 @@ const constants = require('./constants');
1414// App Setup
1515const app = express ( ) ;
1616
17- if ( config . rateLimit . enabled ) {
18- // As we are behind a nginx-proxy
19- // see https://expressjs.com/en/guide/behind-proxies.html
20- app . set ( 'trust proxy' , 1 ) ;
17+ if ( config . trustProxy . enabled ) {
18+ app . set ( 'trust proxy' , config . trustProxy . value ) ;
2119}
2220
2321// Logger
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ const displayConfigurationStatus = () => {
4949 console . log ( chalk . gray ( `[*] Helmet: ${ config . helmet . enabled } ` ) ) ;
5050 console . log ( chalk . gray ( `[*] Morgan: ${ config . morgan . enabled } ` ) ) ;
5151 console . log ( chalk . gray ( `[*] RateLimit: ${ config . rateLimit . enabled } ` ) ) ;
52+ console . log ( chalk . gray ( `[*] TrustProxy: ${ config . trustProxy . enabled } ` ) ) ;
5253} ;
5354
5455displayConfigurationStatus ( ) ;
You can’t perform that action at this time.
0 commit comments