gpt4 book ai didi

javascript - Passport.js 和 MongoStore 错误 "Connection strategy not found at MongoStore"

转载 作者:可可西里 更新时间:2023-11-01 09:20:44 25 4
gpt4 key购买 nike

我的 Node.js 服务器出现了这个奇怪的错误:

 Error: Connection strategy not found
at MongoStore (/Users/amills001c/WebstormProjects/lectal_all/manager/node_modules/connect-mongo/src/index.js:100:23)
at Object.<anonymous> (/Users/amills001c/WebstormProjects/lectal_all/manager/app.js:42:12)
at Module._compile (module.js:425:26)

我们在 Express 中使用 Passport。

错误发生在以下代码段中的 mongoose_connection: mongoose.connection 行:

app.use(expressSession({
secret: 'foobar',
cookie: {
secure: false,
maxage: 1160000000,
resave: true,
saveUninitialized: true
},
store: new MongoStore({
mongoose_connection: mongoose.connection /*<== error happens here*/
})
}));

这是什么错误,我该如何解决?

最佳答案

根据 docs ,我认为那一行应该是:

store: new MongoStore({
mongooseConnection: mongoose.connection
});

使用 mongooseConnection 而不是 mongoose_connection

关于javascript - Passport.js 和 MongoStore 错误 "Connection strategy not found at MongoStore",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34404166/

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