Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

express-session deprecated req.secret; provide secret option app.js:27:9

I typed npm start to run my program but this is the comment that U received in the terminal: express-session deprecated req.secret; provide secret option app.js:27:9. I don't understand how this issue needs to be fixed. This is the code from app.js:27:9

app.use(session({
    store: new FileStore(),
    secret: process.env.SESSION_SECRET,
    resave: false,
    saveUninitialized: true,
    is_logged_in: false,
}))
like image 990
Rhonda Mckenney Avatar asked Aug 14 '20 17:08

Rhonda Mckenney


2 Answers

Make sure you added the SESSION_SECRET in .env file. If yes, then in your app.js, add this

const dotenv = require('dotenv').config()

like image 84
Nitin Khandagale Avatar answered Oct 23 '22 12:10

Nitin Khandagale


You need to load all your environment variables. at line one on the server.js file write this...

if (process.env.NODE_ENV !== 'production') { require('dotenv').config() }

like image 1
Tsogang Mosweswe Avatar answered Oct 23 '22 11:10

Tsogang Mosweswe