RT。 请问是超时的原因吗。 补充app.js代码: const Koa = require(‘koa’) const app = new Koa(); const router = require(‘koa-router’)() const bodyParser = require(‘koa-bodyparser’);
//路由 const index = require(’./routes/index’); const user = require(’./routes/user’); const role = require(’./routes/role’);
const session = require(‘koa-session-minimal’); const MysqlStore = require(‘koa-mysql-session’); const config = require(’./config/index’); const views = require(‘koa-views’) const static = require(‘koa-static’);
//超时处理
// session存储配置 const sessionMysqlConfig= { port:config.database.PORT, user: config.database.USERNAME, password: config.database.PASSWORD, database: config.database.DATABASE, host: config.database.HOST } // 配置session中间件 app.use(session({ key: ‘USER_SID’, store: new MysqlStore(sessionMysqlConfig), cookie: { // 与 cookie 相关的配置 domain: ‘localhost’, // 写 cookie 所在的域名 path: ‘/’, // 写 cookie 所在的路径 maxAge: 1000 * 60 *300, // cookie 有效时长 httpOnly: true, // 是否只用于 http 请求中获取 overwrite: false // 是否允许重写 } })) app.use(bodyParser()); // 将 public 目录设置为静态资源目录 const main = static(__dirname + ‘/public’); app.use(main);
app.use(views(__dirname + ‘/views’, { map : {html:‘ejs’} }));
// 路由 app.use(user.routes()).use(user.allowedMethods()) app.use(index.routes()).use(index.allowedMethods()) app.use(role.routes()).use(role.allowedMethods())
app.listen(3000, () => { console.log(‘server is running at http://localhost:3000’) })