gpt4 book ai didi

html - 错误 : secret option required for sessions (espress session)

转载 作者:行者123 更新时间:2023-12-05 06:34:51 24 4
gpt4 key购买 nike

当我尝试使用 apache 和自签名 ssl 证书在本地主机上运行我的站点时,我总是遇到同样的错误。我不知道为什么会出现此错误。这是我的session持久化,不知道有没有错误,但是我想不出来....再往下可以找到错误。

我现在对这个问题很迷茫

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

最佳答案

这是帮助我解决错误的原因,

const app = express();
app.use(session({ secret: 'somevalue' }));

关于html - 错误 : secret option required for sessions (espress session),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49987007/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com