Merge branch 'feature/redis' into 'release/6.9.2'
Feature/redis See merge request !1742
Showing
3 changed files
with
18 additions
and
5 deletions
@@ -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 | + // 如果是非m.yohobuy.com域名(无法设置sessionid到cookie域名不同)且是爬虫访问,session降级使用cookiesession | ||
92 | + req.session = { | ||
93 | + degrage: true | ||
94 | + }; | ||
95 | + } | ||
85 | next(); | 96 | next(); |
86 | }); | 97 | }); |
87 | 98 |
@@ -13,9 +13,9 @@ const isTest = process.env.NODE_ENV === 'test3' || process.env.NODE_ENV === 'tes | @@ -13,9 +13,9 @@ 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 | 17 | ||
18 | - service: 'http://service.yoho.cn/', | 18 | + // service: 'http://service.yoho.cn/', |
19 | 19 | ||
20 | // yoLuck: 'https://action.yoho.cn', | 20 | // yoLuck: 'https://action.yoho.cn', |
21 | 21 | ||
@@ -28,8 +28,8 @@ const domains = { | @@ -28,8 +28,8 @@ const domains = { | ||
28 | 28 | ||
29 | // platformApi: 'http://172.16.6.210:8088/', | 29 | // platformApi: 'http://172.16.6.210:8088/', |
30 | 30 | ||
31 | - // api: 'http://api-test3.dev.yohocorp.com/', | ||
32 | - // service: 'http://api-test3.dev.yohocorp.com/', | 31 | + api: 'http://api-test3.dev.yohocorp.com/', |
32 | + service: 'http://api-test3.dev.yohocorp.com/', | ||
33 | liveApi: 'http://testapi.live.yohops.com:9999/', | 33 | liveApi: 'http://testapi.live.yohops.com:9999/', |
34 | singleApi: 'http://api-test3.dev.yohocorp.com/', | 34 | singleApi: 'http://api-test3.dev.yohocorp.com/', |
35 | 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/', |
@@ -61,6 +61,7 @@ module.exports = { | @@ -61,6 +61,7 @@ module.exports = { | ||
61 | signExtend: { | 61 | signExtend: { |
62 | business_line: 'yohobuy' | 62 | business_line: 'yohobuy' |
63 | }, | 63 | }, |
64 | + aliasDomains: ['activity.yoho.cn'], | ||
64 | report: { | 65 | report: { |
65 | host: 'badjs.yoho.cn', | 66 | host: 'badjs.yoho.cn', |
66 | port: 80, | 67 | port: 80, |
@@ -20,7 +20,8 @@ function yohoSession(opts) { | @@ -20,7 +20,8 @@ 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 | + // 如果存在session并且没有被降级,且移除redis开关没开,则继续使用session redis | ||
24 | req.sessionError = false; | 25 | req.sessionError = false; |
25 | } else { | 26 | } else { |
26 | // 重建 session | 27 | // 重建 session |
-
Please register or login to post a comment