...
|
...
|
@@ -59,6 +59,7 @@ exports.serverError = () => { |
|
|
|
|
|
const uid = req.user ? req.user.uid : 0;
|
|
|
const udid = _.get(req, 'cookies.udid', 'yoho');
|
|
|
let errorCode = 500;
|
|
|
|
|
|
err = err || {
|
|
|
code: 500
|
...
|
...
|
@@ -102,7 +103,7 @@ exports.serverError = () => { |
|
|
if (err.code === 9999991 || err.code === 9999992) {
|
|
|
let remoteIp = req.yoho.clientIp;
|
|
|
|
|
|
const isHuman = await cache.getAsync(`${config.app}:limiter:ishuman:${remoteIp}`);
|
|
|
const isHuman = await cache.getAsync(`${config.app}:limiter:api:ishuman:${remoteIp}`);
|
|
|
|
|
|
if (!isHuman) {
|
|
|
if (remoteIp.indexOf(',') > 0) {
|
...
|
...
|
@@ -117,6 +118,7 @@ exports.serverError = () => { |
|
|
refer: req.protocol + '://' + req.get('host') + req.originalUrl
|
|
|
});
|
|
|
|
|
|
req.session.apiLimitValidate = true;
|
|
|
if (req.xhr) {
|
|
|
return res.status(510).json({
|
|
|
code: err.code,
|
...
|
...
|
@@ -126,12 +128,13 @@ exports.serverError = () => { |
|
|
|
|
|
return res.redirect(limitPage);
|
|
|
}
|
|
|
errorCode = 510;
|
|
|
}
|
|
|
|
|
|
if (!res.headersSent) {
|
|
|
if (req.xhr) {
|
|
|
return res.status(500).json({
|
|
|
code: 500,
|
|
|
return res.status(errorCode).json({
|
|
|
code: errorCode,
|
|
|
message: '服务器错误!'
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -139,7 +142,7 @@ exports.serverError = () => { |
|
|
const renderErrPage = (result) => {
|
|
|
result = result || {};
|
|
|
|
|
|
res.status(500).render('error/500', {
|
|
|
res.status(errorCode).render(`error/${errorCode}`, {
|
|
|
module: 'common',
|
|
|
page: 'error',
|
|
|
err: err,
|
...
|
...
|
|