提交 95428669 authored 作者: GOD_ZYX's avatar GOD_ZYX

update

上级 7bcf3851
......@@ -68,7 +68,6 @@
"node-sass": "^4.10.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"postcss-loader": "^3.0.0",
"promise.prototype.finally": "^3.1.0",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"uglifyjs-webpack-plugin": "^2.0.1",
......@@ -92,6 +91,7 @@
"form-data": "^2.3.3",
"lodash": "^4.17.11",
"md5-node": "^1.0.1",
"promise.prototype.finally": "^3.1.0",
"multer": "^1.4.1"
}
}
......@@ -12,6 +12,8 @@ const _ = require('lodash')
const md5 = require('md5-node')
const fs = require('fs')
const path = require('path')
/* 支持 finally函数 */
require('promise.prototype.finally').shim()
/**
* 禁止响应头 中设置 cookie值
......@@ -92,19 +94,19 @@ const agentProcessor = () => {
axios.defaults.headers = headers
axios.defaults.withCredentials = true
/* 日志记录,重新修改 2019.01.17 */
// let _log = {
// reqTime: timestamp, // 请求时长
// sys: req.headers['tenant'], // 系统
// status: '', // 请求状态
// name: req.headers['cur-name'], // 姓名
// auth: req.headers['cur-auth'], // 账号
// IP: '', // IP值
// uuid: uuid, // uuid
// url: options.url, // 请求地址
// type: '', // 1:视频 2:课后作业 3:作业内容
// self: '', // 根据类型值,自定义 字符串参数
// param: JSON.stringify(options) // 请求参数 JSON str
// }
let _log = {
reqTime: timestamp, // 请求时长
sys: req.headers['tenant'], // 系统
status: '', // 请求状态
name: req.headers['cur-name'], // 姓名
auth: req.headers['cur-auth'], // 账号
IP: '', // IP值
uuid: uuid, // uuid
url: options.url, // 请求地址
type: '', // 1:视频 2:课后作业 3:作业内容
self: '', // 根据类型值,自定义 字符串参数
param: JSON.stringify(options) // 请求参数 JSON str
}
/* 兼容老版本,登录接口 清除_SUP; 退出登录 清除_SUP */
if (/tenant\/user\/login/gi.test(options.url) || /tenant\/user\/code-login/gi.test(options.url) || /v3\/sso\/logout/gi.test(options.url)) {
......@@ -112,34 +114,33 @@ const agentProcessor = () => {
}
/* 重新转发请求 */
axios(options).then((data) => {
// _log.reqTime = (new Date().getTime() - _log.reqTime) + 'ms'
// _log.status = 200
_log.reqTime = (new Date().getTime() - _log.reqTime) + 'ms'
_log.status = 200
setPorxyHeader(data, res)
res.status(200).send(data.data)
}).catch((e) => {
// _log.reqTime = (new Date().getTime() - _log.reqTime) + 'ms'
// _log.status = e.response.status || 500
_log.reqTime = (new Date().getTime() - _log.reqTime) + 'ms'
_log.status = e.response.status || 500
/* 返回执行代码出错 或者 服务器请求错误 */
if (e.response && e.response.data) {
/* 如果未登录 强制 弹出到 登录页 */
setPorxyHeader(e.response, res)
res.status(e.response.status).json(e.response.data)
// console.error(uuid + '\\001' + JSON.stringify(options) + '\\001' + JSON.stringify(e.response))
console.error(uuid + '^A' + JSON.stringify(options) + '^A' + JSON.stringify(e.response))
} else {
res.status(500).json({ message: '系统错误,请稍后重试或联系管理员', errMsg: 'Error Proxy Request or BackData Excute Error', code: 500 })
// console.error(uuid, e)
console.error(uuid, e)
}
}).finally(() => {
let _str = ''
for (let key in _log) {
_str += _log[key] + '^A'
}
console.log(_str + 'end')
})
// finally(() => {
// let _str = ''
// for (let key in _log) {
// _str += _log[key] + '\\001'
// }
// console.log(_str + 'end')
// })
} catch (e) {
res.status(500).json({ message: '系统错误,请稍后重试或联系管理员', errMsg: 'Network Server Excute Error', code: 500 })
// console.error('system error:', uuid, e)
console.error('system error:', uuid, e)
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论