Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
陈峰
6 years ago
Commit
d300fb729103e60f49e72c11e2b003dcf2cdd87d
2 parents
4d2a199b
7bca2e1c
Merge branch 'feature/redis' into 'release/6.9.2'
Feature/redis See merge request
!1742
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
5 deletions
app.js
config/common.js
doraemon/middleware/yoho-session.js
app.js
View file @
d300fb7
...
...
@@ -78,10 +78,21 @@ app.disable('x-powered-by');
app
.
use
(
'/node/status.html'
,
(
req
,
res
)
=>
{
return
res
.
status
(
200
).
end
();
});
app
.
head
(
'*'
,
(
req
,
res
)
=>
{
res
.
status
(
200
).
end
();
});
app
.
use
((
req
,
res
,
next
)
=>
{
req
.
url
=
stringProcess
.
decodeURIComponent
(
req
.
url
)
||
'/404'
;
// 错误的网址编码重定向404
req
.
isApmReport
=
_
.
get
(
req
.
app
.
locals
,
'wap.open.bughd'
,
false
);
// 把错误上报的开关绑定到上下文,node-lib 库要使用
let
isSpider
=
/spider/i
.
test
(
req
.
get
(
'User-Agent'
)
||
''
);
if
(
config
.
aliasDomains
.
some
(
d
=>
d
===
req
.
hostname
)
||
isSpider
)
{
// 如果是非m.yohobuy.com域名(无法设置sessionid到cookie域名不同)且是爬虫访问,session降级使用cookiesession
req
.
session
=
{
degrage
:
true
};
}
next
();
});
...
...
config/common.js
View file @
d300fb7
...
...
@@ -13,9 +13,9 @@ const isTest = process.env.NODE_ENV === 'test3' || process.env.NODE_ENV === 'tes
const
domains
=
{
api
:
'http://api.yoho.cn/'
,
//
api: 'http://api.yoho.cn/',
service
:
'http://service.yoho.cn/'
,
//
service: 'http://service.yoho.cn/',
// yoLuck: 'https://action.yoho.cn',
...
...
@@ -28,8 +28,8 @@ const domains = {
// platformApi: 'http://172.16.6.210:8088/',
// api: 'http://api-test3.dev.yohocorp.com/',
// service: 'http://api-test3.dev.yohocorp.com/',
api
:
'http://api-test3.dev.yohocorp.com/'
,
service
:
'http://api-test3.dev.yohocorp.com/'
,
liveApi
:
'http://testapi.live.yohops.com:9999/'
,
singleApi
:
'http://api-test3.dev.yohocorp.com/'
,
ufo
:
'http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/'
,
...
...
@@ -61,6 +61,7 @@ module.exports = {
signExtend
:
{
business_line
:
'yohobuy'
},
aliasDomains
:
[
'activity.yoho.cn'
],
report
:
{
host
:
'badjs.yoho.cn'
,
port
:
80
,
...
...
doraemon/middleware/yoho-session.js
View file @
d300fb7
...
...
@@ -20,7 +20,8 @@ function yohoSession(opts) {
opts
.
backSession
=
opts
.
backSession
||
'session2'
;
if
(
req
.
session
&&
!
notUseRedis
)
{
if
(
req
.
session
&&
!
req
.
session
.
degrage
&&
!
notUseRedis
)
{
// 如果存在session并且没有被降级,且移除redis开关没开,则继续使用session redis
req
.
sessionError
=
false
;
}
else
{
// 重建 session
...
...
Please
register
or
login
to post a comment