当我尝试使用apache和自签名ssl证书在localhost上运行我的站点时,我总是得到相同的错误。我不知道为什么会出现这个错误。 这是我的会话持久性,我不知道是否有一个错误,但我无法想象....进一步下来你可以找到错误。
目前我对这个问题很遗憾
app.use(cookieParser(sessionSecret));
app.use( session( {
store: sessionStore,
secret: sessionSecret, resave: false, saveUninitialized: true,
cookie: {secure: true, maxAge:24*60*60*1000},
genid: function (req) {return uuid.v4()}
}));
app.get('/login*', function (req, res) {console.log("login session is: "+req.session); loadSelectedFile(req, res);});
Error: secret option required for sessions
at session (C:\xampp\htdocs\node_modules\express-session\index.js:167:12)
at Layer.handle [as handle_request] (C:\xampp\htdocs\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (C:\xampp\htdocs\node_modules\express\lib\router\index.js:317:13)
at C:\xampp\htdocs\node_modules\express\lib\router\index.js:284:7
at Function.process_params (C:\xampp\htdocs\node_modules\express\lib\router\index.js:335:12)
at next (C:\xampp\htdocs\node_modules\express\lib\router\index.js:275:10)
at cookieParser (C:\xampp\htdocs\node_modules\cookie-parser\index.js:56:14)
at Layer.handle [as handle_request] (C:\xampp\htdocs\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (C:\xampp\htdocs\node_modules\express\lib\router\index.js:317:13)
at C:\xampp\htdocs\node_modules\express\lib\router\index.js:284:7
at Function.process_params (C:\xampp\htdocs\node_modules\express\lib\router\index.js:335:12)
at next (C:\xampp\htdocs\node_modules\express\lib\router\index.js:275:10)
at expressInit (C:\xampp\htdocs\node_modules\express\lib\middleware\init.js:40:5)
at Layer.handle [as handle_request] (C:\xampp\htdocs\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (C:\xampp\htdocs\node_modules\express\lib\router\index.js:317:13)
at C:\xampp\htdocs\node_modules\express\lib\router\index.js:284:7
答案 0 :(得分:1)
这就是帮助我解决错误的原因
const app = express();
app.use(session({ secret: 'somevalue' }));