Shun Miyazawa 3 سال پیش
والد
کامیت
d8a9756bb6
1فایلهای تغییر یافته به همراه6 افزوده شده و 6 حذف شده
  1. 6 6
      packages/app/src/server/crowi/express-init.js

+ 6 - 6
packages/app/src/server/crowi/express-init.js

@@ -67,15 +67,15 @@ module.exports = function(crowi, app) {
   const trustProxyCsv = configManager.getConfig('crowi', 'security:trustProxyCsv');
   const trustProxyHops = configManager.getConfig('crowi', 'security:trustProxyHops');
 
-  const isNotSpec = [trustProxyBool, trustProxyCsv, trustProxyHops].filter(trustProxy => trustProxy != null).length !== 1;
+  const trustProxy = trustProxyBool ?? trustProxyCsv ?? trustProxyHops;
 
   try {
-    const trustProxy = trustProxyBool ?? trustProxyCsv ?? trustProxyHops;
-    if (isNotSpec) {
-      // eslint-disable-next-line max-len
-      logger.warn(`If more than one TRUST_PROXY_ ~ environment variable is set, the values are set in the following order of inequality size (BOOL > CSV > HOPS) first. Set value: ${trustProxy}`);
-    }
     if (trustProxy != null) {
+      const isNotSpec = [trustProxyBool, trustProxyCsv, trustProxyHops].filter(trustProxy => trustProxy != null).length !== 1;
+      if (isNotSpec) {
+        // eslint-disable-next-line max-len
+        logger.warn(`If more than one TRUST_PROXY_ ~ environment variable is set, the values are set in the following order of inequality size (BOOL > CSV > HOPS) first. Set value: ${trustProxy}`);
+      }
       app.set('trust proxy', trustProxy);
     }
   }