I am working on a simple login system, but it seems like the session is not saved
i have made a simple code for testing, can anyone tell me what is wrong with it ? i am
All about changing the sequence of Session config and routes config in
Server.js
file
Before: Error
require("./startup/cors")(app);
require("./startup/passport/passport-setup")();
require("./startup/logging")();
require("./startup/validation")();
//require("./startup/db")();
require("./startup/prod")(app);
require("./routes/index")(app);
app.use(
session({
secret: 'keyboard cat',//process.env.SESSION_KEY,// Used to compute a hash
resave: false,
saveUninitialized: false,
store: new MongoStore({ mongooseConnection: mongoose.connection }),// Store session on DB
})
);
After: Correct
app.use(
session({
secret: 'keyboard cat',//process.env.SESSION_KEY,// Used to compute a hash
resave: false,
saveUninitialized: false,
store: new MongoStore({ mongooseConnection: mongoose.connection }),// Store session on DB
})
);
require("./startup/cors")(app);
require("./startup/passport/passport-setup")();
require("./startup/logging")();
require("./startup/validation")();
//require("./startup/db")();
require("./startup/prod")(app);
require("./routes/index")(app);