Cartion
Cartion

Reputation: 157

Adding Redis store to Express server causes strategy to not run

Trying to add a redis store to my express server. When I run the server without adding the redisStore in the app.use(session(()) section I'm able to login without any problems. The issue is as soon as I add store: new RedisStore() the login will hang indefinitely and not call any of the console.logs inside my strategy.

Ive tried to figure out what could cause this but I've never had this issue before using a redis store. The redisclient connects successfully and outputs the console.log that it has connected so I have all of the correct server information.

Removed imports that arent important to make it easier to read

const redisClient = createClient({
  url: `redis://${process.env.REDIS_HOST}:${process.env.REDIS_PORT}`,
  password: process.env.REDIS_PASSWORD,
});
redisClient.connect();

redisClient.on('connect', function (err) {
  console.log('Connected to redis successfully');
});

redisClient.on('error', function (err) {
  console.log('Could not establish a connection with redis. ' + err);
});
const RedisStore = connectRedis(session);

Upvotes: 0

Views: 179

Answers (1)

Leibale Eidelman
Leibale Eidelman

Reputation: 3184

connect-redis only supports v4 with legacyMode. See here.

Upvotes: 2

Related Questions