[英]Express.js and connect-mongo session “TypeError: Cannot read property 'upserted' of undefined”
I am trying to store sessions using connect-mongo module, however I get the following Error: 我正在尝试使用connect-mongo模块存储会话,但是出现以下错误:
TypeError: Cannot read property 'upserted' of undefined
The usage of connect-mongo
looks as follows: connect-mongo
的用法如下所示:
import session from 'express-session';
const MongoStore = require('connect-mongo')(session);
app.use(session({
secret: 'SECRET',
store: new MongoStore({ url: 'mongodb://mongo:27017/sessions' }),
saveUninitialized: true,
resave: false
}));
At the same time, I can see that session entries are being created on every page reload with the following contents: 同时,我可以看到在重新加载的每个页面上都在创建会话条目,其中包含以下内容:
{
"_id": "zO68C8OuARTUblw3EqHfUikR_IIHRaQq",
"session": "{\"cookie\": \"originalMaxAge\":null,\"expires\":null,\"httpOnly\":true,\"path\":\"/\" }}",
"expires": new Date(1470779765287)
}
And the expiration date is set to 14 days from the creation timestamp (default value) 并将到期日期设置为自创建时间戳记起的14天(默认值)
Package versions used: 使用的软件包版本:
"cookie-parser": "^1.4.3",
"connect-mongo": "^1.3.1",
"express": "~4.0.0",
"express-session": "^1.14.0",
我在connect-mongo信息库上打开了一个问题 ,确实,该问题已在最新版本1.3.2中解决:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.