我正在使用(node js,express)开发一个Web应用程序。在我的本地计算机上,如果我的网站保持不活动状态/没有向服务器发送任何请求,则我保持登录状态。但是在在线部署此应用程序后,如果我没有向服务器发送任何请求,则服务器将在一分钟后终止连接。我已经在代码中尝试了maxage / expire,但是没有任何效果。
这是index.js文件
var express = require('express'),
app = express(),
bodyParser = require('body-parser'),
passport = require('passport'),
flash = require('connect-flash'),
session = require('express-session'),
LocalStrategy = require('passport-local').Strategy;
// For sql connection
var connection = require('./database/connection.js');
// For routes
var loginRoute = require('./routes/login.js'),
logOutRoute = require('./routes/logOut.js'),
remainingRoutes = require('./routes/remaining.js'),
adminRoutes = require('./routes/adminRoutes.js');
app.use(bodyParser.json({limit: "50mb"}));
app.use(bodyParser.urlencoded({limit: "50mb", extended: true,
parameterLimit:50000}));
app.use(express.static("public"));
app.set("view engine", "ejs" );
app.use(require('express-session')({
secret: 'sjnsjdcjds',
resave: false,
saveUninitialized: false,
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
//=============================================
// ROUTES
//=============================================
app.use(loginRoute);
app.use(logOutRoute);
app.use(remainingRoutes);
app.use(adminRoutes);
//=============================================
// SERVER
//=============================================
app.listen(4000,function(){
console.log("Welcome to land");
});
//====