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
Email Patches
Plain Diff
Browse Files
Authored by
陈峰
6 years ago
Commit
74451bca125b20dcbc6ea07bad43fe2bcb974247
1 parent
b7a53b4c
commit
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
5 deletions
app.js
config/common.js
doraemon/middleware/yoho-session.js
app.js
View file @
74451bc
...
...
@@ -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
)
{
console
.
log
(
'close session'
);
req
.
session
=
{
degrage
:
true
};
}
next
();
});
...
...
@@ -115,6 +126,7 @@ app.use(compression());
require
(
'./doraemon/middleware/yoho-session'
)(
app
);
app
.
use
((
req
,
res
,
next
)
=>
{
console
.
log
(
req
.
session
);
req
.
user
=
{};
// 全局的用户数据
req
.
yoho
=
{};
// req和res绑定yoho对象,用于传递全局数据, 如req.yoho.channel等
req
.
app
.
locals
.
wap
=
app
.
locals
.
wap
;
// zookeper对象赋值
...
...
config/common.js
View file @
74451bc
...
...
@@ -13,9 +13,10 @@ 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',
// liveApi: 'http://testapi.live.yohops.com:9999/',
...
...
@@ -27,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/'
,
...
...
@@ -60,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 @
74451bc
...
...
@@ -20,7 +20,7 @@ function yohoSession(opts) {
opts
.
backSession
=
opts
.
backSession
||
'session2'
;
if
(
req
.
session
&&
!
notUseRedis
)
{
if
(
req
.
session
&&
!
req
.
session
.
degrage
&&
!
notUseRedis
)
{
req
.
sessionError
=
false
;
}
else
{
// 重建 session
...
...
Please
register
or
login
to post a comment