提交 458faeec authored 作者: GOD_ZYX's avatar GOD_ZYX

update

上级 25a58cec
...@@ -2,6 +2,8 @@ const state = process.env.NODE_ENV ...@@ -2,6 +2,8 @@ const state = process.env.NODE_ENV
let conf = {} let conf = {}
if (state === 'test') { if (state === 'test') {
conf.agentApiUrl = 'http://api.ezijing.com/' conf.agentApiUrl = 'http://api.ezijing.com/'
// conf.agentApiUrl = 'http://10.1.1.5:8024/'
// conf.agentApiUrl = 'http://192.168.3.254:8081'
} else if (state === 'production') { } else if (state === 'production') {
conf.agentApiUrl = 'http://api.ezijing.com/' conf.agentApiUrl = 'http://api.ezijing.com/'
} }
......
...@@ -38,7 +38,7 @@ const agentProcessor = () => { ...@@ -38,7 +38,7 @@ const agentProcessor = () => {
try { try {
options = { options = {
timeout: 30 * 1000, timeout: 30 * 1000,
url: req.params[0], url: req.params[0], // .replace(/tenant\//gi, '')
baseURL: conf.agentApiUrl, baseURL: conf.agentApiUrl,
method: req.method, method: req.method,
data: req.body, data: req.body,
...@@ -132,6 +132,24 @@ const agentProcessor = () => { ...@@ -132,6 +132,24 @@ const agentProcessor = () => {
} }
}) })
/* 处理特殊请求,在域名为e-learing2时生效 */
let _stoken = ''
for (let i = 0; i < _cookieArr.length; i++) {
if (/_stoken=/gi.test(_cookieArr[i])) {
_stoken = _cookieArr[i].split('=')[1]
break
}
}
if (_stoken) {
headers['stoken'] = _stoken
}
if (global.stoken) {
headers['stoken'] = global.stoken
let opts = { path: '/', domain: '.ezijing.com', expires: null, httpOnly: true }
res.cookie('_stoken', global.stoken, opts)
global.stoken = 0
}
/* 重新转发请求 */ /* 重新转发请求 */
axios(options).then((data) => { axios(options).then((data) => {
_log.reqTime = (new Date().getTime() - _log.reqTime) + 'ms' _log.reqTime = (new Date().getTime() - _log.reqTime) + 'ms'
......
...@@ -12,8 +12,10 @@ app.get('/', (req, res) => { ...@@ -12,8 +12,10 @@ app.get('/', (req, res) => {
/* 增加 限定条件,如果是 e-learning2 子域名,那么 referer 为指定 域名 否则不能打开 */ /* 增加 限定条件,如果是 e-learning2 子域名,那么 referer 为指定 域名 否则不能打开 */
if (/^e-learning2\./.test(req.headers.host)) { if (/^e-learning2\./.test(req.headers.host)) {
if (/(sofia\.tenant\.ezijing)|(sofia-x\.ezijing)|(course\.ezijing)|(course3\.ezijing)/.test(req.headers.referer)) { if (/(sofia\.tenant\.ezijing)|(sofia-x\.ezijing)|(course\.ezijing)|(course3\.ezijing)/.test(req.headers.referer)) {
global.stoken = req.query.stoken || 0
res.sendFile(path.join(__dirname, '../client-dist/index.html')) res.sendFile(path.join(__dirname, '../client-dist/index.html'))
} else { } else {
global.stoken = 0
res.send('当前页面打开方式不对') res.send('当前页面打开方式不对')
} }
} else { } else {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论