简体   繁体   中英

Internal Server Error (Heroku Console)

Good day guys i'm having a problem about the cookie session im making. I want to get rid of the error

connect.session() memorystore is not designed for a production environment

so i've red a forum that says it's normal and if i want to get rid of the error then use a connect-redis and yeah it works but the problem is it gives me an error when opening my app(not in the console);

Internal Server Error

and on my console its returning the

return next(new Error('Oh no')) //handle error

Here is my code so far:

app.set('trust proxy', 1);

app.use(session({
cookie:{
    secure: true,
    maxAge:60000
       },
store: new RedisStore({host:'https://pektos6.herokuapp.com', port: port}),
secret: 'secret',
saveUninitialized: true,
resave: false
}));

app.use(function(req,res,next){
if(!req.session){
    return next(new Error('Oh no')) //handle error
}
next() //otherwise continue
});

What i did here is

var session = require('cookie-session'); 
//instead of
//var session = require('express-session');

app.use(session({
    secret: 'secret',
    saveUninitialized: true,
    resave: false
    cookie:{secure:true}
}));

and the memory leak is gone

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM