guoziyun пре 1 година
родитељ
комит
37b23b9571
3 измењених фајлова са 12 додато и 10 уклоњено
  1. 2 1
      app.js
  2. 2 1
      routes/index.js
  3. 8 8
      views/index.ejs

+ 2 - 1
app.js

@@ -9,6 +9,8 @@ const cookieParser = require('cookie-parser');
 const bodyParser = require('body-parser');
 const bodyParser = require('body-parser');
 const authChecker = require('./libs/auth/checker');
 const authChecker = require('./libs/auth/checker');
 
 
+app.set('trust proxy', 1) //trust first proxy, get ip
+
 // 设置视图引擎为EJS
 // 设置视图引擎为EJS
 app.set('view engine', 'ejs');
 app.set('view engine', 'ejs');
 
 
@@ -41,7 +43,6 @@ app.use(bodyParser.urlencoded({
 }));
 }));
 
 
 
 
-
 app.use('/napi/web/auth', require('./routes/napi/web/auth'));
 app.use('/napi/web/auth', require('./routes/napi/web/auth'));
 app.use('/napi/web/menu', authChecker.checkLogin, require('./routes/napi/web/menu'));
 app.use('/napi/web/menu', authChecker.checkLogin, require('./routes/napi/web/menu'));
 app.use('/napi/web/art', authChecker.checkLogin, require('./routes/napi/web/art'));
 app.use('/napi/web/art', authChecker.checkLogin, require('./routes/napi/web/art'));

+ 2 - 1
routes/index.js

@@ -45,7 +45,7 @@ router.get('/', (req, res, next) => {
   }
   }
   if (!req.cookies.lang || req.cookies.lang != lang) {
   if (!req.cookies.lang || req.cookies.lang != lang) {
     res.cookie('lang', lang, config.cookie);
     res.cookie('lang', lang, config.cookie);
-    console.log(`set cookie: lang=${lang}`);
+    console.log(`${req.originalUrl} set cookie: lang=${lang}`);
   }
   }
   return res.redirect(`/${lang}`);
   return res.redirect(`/${lang}`);
 });
 });
@@ -60,6 +60,7 @@ router.get(/^\/(en|zh|es|pt|ja)$/, function (req, res, next) {  // 限制严格
     let [lang] = params;
     let [lang] = params;
     if (!req.cookies.lang || req.cookies.lang != lang) {
     if (!req.cookies.lang || req.cookies.lang != lang) {
       res.cookie('lang', lang, config.cookie);
       res.cookie('lang', lang, config.cookie);
+      console.log(`${req.originalUrl} set cookie: lang=${lang}`);
     }
     }
 
 
     let host = config.cdnHost ?? config.resHost;
     let host = config.cdnHost ?? config.resHost;

+ 8 - 8
views/index.ejs

@@ -23,14 +23,14 @@
 
 
 <body>
 <body>
   <%- include('header') %>
   <%- include('header') %>
-    <%- include('banner') %>
-      <%- include('latest-section') %>
-        <%- include('album-section') %>
-          <%- include('hot-section') %>
-            <%- include('designer-section') %>
-              <%- include('special-section') %>
-                <%- include('footer') %>
-                  <div style="height: 50px;"></div>
+  <!-- <%- include('banner') %> -->
+  <%- include('latest-section') %>
+  <%- include('album-section') %>
+  <%- include('hot-section') %>
+  <%- include('designer-section') %>
+  <%- include('special-section') %>
+  <%- include('footer') %>
+  <div style="height: 50px;"></div>
 </body>
 </body>
 
 
 </html>
 </html>