Authored by 陈峰

commit

@@ -78,10 +78,21 @@ app.disable('x-powered-by'); @@ -78,10 +78,21 @@ app.disable('x-powered-by');
78 app.use('/node/status.html', (req, res) => { 78 app.use('/node/status.html', (req, res) => {
79 return res.status(200).end(); 79 return res.status(200).end();
80 }); 80 });
  81 +app.head('*', (req, res) => {
  82 + res.status(200).end();
  83 +});
81 84
82 app.use((req, res, next) => { 85 app.use((req, res, next) => {
83 req.url = stringProcess.decodeURIComponent(req.url) || '/404';// 错误的网址编码重定向404 86 req.url = stringProcess.decodeURIComponent(req.url) || '/404';// 错误的网址编码重定向404
84 req.isApmReport = _.get(req.app.locals, 'wap.open.bughd', false); // 把错误上报的开关绑定到上下文,node-lib 库要使用 87 req.isApmReport = _.get(req.app.locals, 'wap.open.bughd', false); // 把错误上报的开关绑定到上下文,node-lib 库要使用
  88 + let isSpider = /spider/i.test(req.get('User-Agent') || '');
  89 +
  90 + if (config.aliasDomains.some(d => d === req.hostname) || isSpider) {
  91 + console.log('close session');
  92 + req.session = {
  93 + degrage: true
  94 + };
  95 + }
85 next(); 96 next();
86 }); 97 });
87 98
@@ -115,6 +126,7 @@ app.use(compression()); @@ -115,6 +126,7 @@ app.use(compression());
115 require('./doraemon/middleware/yoho-session')(app); 126 require('./doraemon/middleware/yoho-session')(app);
116 127
117 app.use((req, res, next) => { 128 app.use((req, res, next) => {
  129 + console.log(req.session);
118 req.user = {}; // 全局的用户数据 130 req.user = {}; // 全局的用户数据
119 req.yoho = {}; // req和res绑定yoho对象,用于传递全局数据, 如req.yoho.channel等 131 req.yoho = {}; // req和res绑定yoho对象,用于传递全局数据, 如req.yoho.channel等
120 req.app.locals.wap = app.locals.wap; // zookeper对象赋值 132 req.app.locals.wap = app.locals.wap; // zookeper对象赋值
@@ -13,9 +13,10 @@ const isTest = process.env.NODE_ENV === 'test3' || process.env.NODE_ENV === 'tes @@ -13,9 +13,10 @@ const isTest = process.env.NODE_ENV === 'test3' || process.env.NODE_ENV === 'tes
13 13
14 const domains = { 14 const domains = {
15 15
16 - // api: 'http://api.yoho.cn/', 16 + api: 'http://api.yoho.cn/',
  17 +
  18 + service: 'http://service.yoho.cn/',
17 19
18 - // service: 'http://service.yoho.cn/',  
19 // yoLuck: 'https://action.yoho.cn', 20 // yoLuck: 'https://action.yoho.cn',
20 21
21 // liveApi: 'http://testapi.live.yohops.com:9999/', 22 // liveApi: 'http://testapi.live.yohops.com:9999/',
@@ -27,8 +28,8 @@ const domains = { @@ -27,8 +28,8 @@ const domains = {
27 28
28 // platformApi: 'http://172.16.6.210:8088/', 29 // platformApi: 'http://172.16.6.210:8088/',
29 30
30 - api: 'http://api-test3.dev.yohocorp.com/',  
31 - service: 'http://api-test3.dev.yohocorp.com/', 31 + // api: 'http://api-test3.dev.yohocorp.com/',
  32 + // service: 'http://api-test3.dev.yohocorp.com/',
32 liveApi: 'http://testapi.live.yohops.com:9999/', 33 liveApi: 'http://testapi.live.yohops.com:9999/',
33 singleApi: 'http://api-test3.dev.yohocorp.com/', 34 singleApi: 'http://api-test3.dev.yohocorp.com/',
34 ufo: 'http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/', 35 ufo: 'http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/',
@@ -60,6 +61,7 @@ module.exports = { @@ -60,6 +61,7 @@ module.exports = {
60 signExtend: { 61 signExtend: {
61 business_line: 'yohobuy' 62 business_line: 'yohobuy'
62 }, 63 },
  64 + aliasDomains: ['activity.yoho.cn'],
63 report: { 65 report: {
64 host: 'badjs.yoho.cn', 66 host: 'badjs.yoho.cn',
65 port: 80, 67 port: 80,
@@ -20,7 +20,7 @@ function yohoSession(opts) { @@ -20,7 +20,7 @@ function yohoSession(opts) {
20 20
21 opts.backSession = opts.backSession || 'session2'; 21 opts.backSession = opts.backSession || 'session2';
22 22
23 - if (req.session && !notUseRedis) { 23 + if (req.session && !req.session.degrage && !notUseRedis) {
24 req.sessionError = false; 24 req.sessionError = false;
25 } else { 25 } else {
26 // 重建 session 26 // 重建 session