在写了有关redis的配置后,在启动node服务时,会报redis连接错误
以下是app.js中有关配置的代码
const session = require(‘express-session’)
const RedisStore = require(‘connect-redis’)(session)
const redisClient = require(’./db/redis’)
const sessionStore = new RedisStore({
client: redisClient
})
app.use(session({
// resave:false,//添加这行
// saveUninitialized: true,//添加这行
secret: ‘WJiol#23123_’,
cookie: {
maxAge: 24 * 60 * 60 * 1000
},
store: sessionStore
}))