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
徐炜
8 years ago
Commit
023698b26a87296cdeea35efdc5abda086a71931
1 parent
b63be47e
错误页面不缓存
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
doraemon/middleware/error-handler.js
doraemon/middleware/error-handler.js
View file @
023698b
...
...
@@ -5,15 +5,22 @@
const
headerModel
=
require
(
'../models/header'
);
const
logger
=
global
.
yoho
.
logger
;
exports
.
notFound
=
()
=>
{
return
(
req
,
res
)
=>
{
res
.
status
(
404
);
const
forceNoCache
=
(
res
)
=>
{
if
(
res
)
{
res
.
set
({
'Cache-Control'
:
'no-cache'
,
Pragma
:
'no-cache'
,
Expires
:
(
new
Date
(
1900
,
0
,
1
,
0
,
0
,
0
,
0
)).
toUTCString
()
});
}
};
exports
.
notFound
=
()
=>
{
return
(
req
,
res
)
=>
{
forceNoCache
(
res
);
res
.
status
(
404
);
if
(
req
.
xhr
)
{
return
res
.
json
({
...
...
@@ -40,11 +47,7 @@ exports.notFound = () => {
*/
exports
.
serverError
=
()
=>
{
return
(
err
,
req
,
res
,
next
)
=>
{
res
.
set
({
'Cache-Control'
:
'no-cache'
,
Pragma
:
'no-cache'
,
Expires
:
(
new
Date
(
1900
,
0
,
1
,
0
,
0
,
0
,
0
)).
toUTCString
()
});
forceNoCache
(
res
);
logger
.
error
(
`
error
at
path
:
$
{
req
.
url
}
`
);
logger
.
error
(
err
);
...
...
Please
register
or
login
to post a comment