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

sesssion 设置

上级 3db9e525
...@@ -3,7 +3,7 @@ let conf = {} ...@@ -3,7 +3,7 @@ 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://10.1.1.5:8024/'
conf.agentApiUrl = 'http://192.168.3.254:8081' // 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/'
} }
......
...@@ -97,8 +97,7 @@ const agentProcessor = () => { ...@@ -97,8 +97,7 @@ const agentProcessor = () => {
url: options.url, // 请求地址 url: options.url, // 请求地址
type: '', // 1:视频 2:课后作业 3:作业内容 type: '', // 1:视频 2:课后作业 3:作业内容
self: '', // 根据类型值,自定义 字符串参数 self: '', // 根据类型值,自定义 字符串参数
param: JSON.stringify(options), // 请求参数 JSON str param: JSON.stringify(options) // 请求参数 JSON str
header: JSON.stringify(headers)
} }
/* 基础info数据,写入文件 */ /* 基础info数据,写入文件 */
...@@ -134,9 +133,16 @@ const agentProcessor = () => { ...@@ -134,9 +133,16 @@ const agentProcessor = () => {
}) })
/* 处理特殊请求,在域名为e-learing2时生效 */ /* 处理特殊请求,在域名为e-learing2时生效 */
if (req.session && req.session._stoken) { // let _STOKEN = ''
headers['stoken'] = req.session._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'] = req.session._stoken
// }
/* 重新转发请求 */ /* 重新转发请求 */
axios(options).then((data) => { axios(options).then((data) => {
......
...@@ -12,14 +12,14 @@ let sessionOpts = { ...@@ -12,14 +12,14 @@ let sessionOpts = {
// Forces a session that is "uninitialized" to be saved to the store. // Forces a session that is "uninitialized" to be saved to the store.
saveUninitialized: true, saveUninitialized: true,
// 设置会话cookie名, 默认是connect.sid // 设置会话cookie名, 默认是connect.sid
// key: 'myapp_sid', key: '_STOKEN',
// If secure is set to true, and you access your site over HTTP, the cookie will not be set. // If secure is set to true, and you access your site over HTTP, the cookie will not be set.
cookie: { maxAge: 1000 * 60 * 60 * 2, secure: false } cookie: { maxAge: 1000 * 60 * 60 * 2, secure: false }
} }
app.set('port', process.env.SERVER_PORT || 3000) app.set('port', process.env.SERVER_PORT || 3000)
app.use(session(sessionOpts)) // app.use(session(sessionOpts))
app.use(history({ verbose: false, index: '/' })) app.use(history({ verbose: false, index: '/' }))
app.get('/', (req, res) => { app.get('/', (req, res) => {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论