-
Notifications
You must be signed in to change notification settings - Fork 568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MongoDBStore session broke, needs a clear fix #14
Comments
//replaced with this solution i found but still broke const mongoStore = require("connect-mongo"); const sessionConfig = { sessionConfig.store.on("error", function (e) { app.use(session(sessionConfig)) |
What's the error that you're getting? |
i ended up with this const secret = process.env.SECRET || 'thisshouldbeabettersecret'; const store = mongoStore.create({ }); // store.on("error", function (e) { const sessionConfig = { // sessionConfig.store.on("error", function (e) { app.use(session(sessionConfig)) |
const store = mongoStore.create({ TypeError: mongoStore.create is not a function |
DId you find the solution for this ?? @Markalot787 |
Assertion failed: You must provide either mongoUrl|clientPromise|client in options Error: Cannot init client. Please provide correct options |
Same issue here, I installed the same version that Colt uses in the videos. |
please see here |
This worked for me. My installed dependency version |
@benilrichards Thanks for sharing this solution, I had similar issue in console "Error: Cannot init client. Please provide correct options", I'm using ("^4.6.0"). Although variable name i used is "MongoStore" instead of "MongoDBStore" and it still worked!
|
still showing me the error with your above code |
const MongoDBStore = require("connect-mongo")(session);
const secret = process.env.SECRET || 'thisshouldbeabettersecret!';
const store = new MongoDBStore({
url: dbUrl,
secret,
touchAfter: 24 * 60 * 60
});
store.on("error", function (e) {
console.log("SESSION STORE ERROR", e)
})
const sessionConfig = {
store,
name: 'session',
secret,
resave: false,
saveUninitialized: true,
cookie: {
httpOnly: true,
// secure: true,
expires: Date.now() + 1000 * 60 * 60 * 24 * 7,
maxAge: 1000 * 60 * 60 * 24 * 7
}
}
app.use(session(sessionConfig));
The text was updated successfully, but these errors were encountered: