I cant make redis work (express-session)

using express-session on nodejs

Hi, at the moment on production it successfuly connects to redis, i know this using redisClient.on('connect', () => console.log('Conectado a Redis!')), but when i try to store a test req.session.test = “test” it wont happen but in my development enviroment (localhost) it works.

  1. Yes my webservice (backend) and my static web are hosted on render, also my redis and my db.

this is my code:

let redisClient = createClient({
  url: process.env.REDIS_URL,
})

redisClient.on('connect', () => console.log('Conectado a Redis!'))
redisClient.on('error', err => console.error('Error al conectar a Redis:', err))
redisClient.connect().catch(console.error)

// Initialize store.
let redisStore = new RedisStore({
  client: redisClient,
})

const sessionMiddleware = session({
  secret: 'supersecreto',
  resave: false,
  saveUninitialized: false,

  cookie: {
    secure: process.env.NODE_ENV === 'production' ? true : false,
    domain: process.env.NODE_ENV === 'production' ? 'avo-pwa.onrender.com' : 'localhost',
    httpOnly: true,
    maxAge: 1000 * 60 * 60 * 24 * 7,
  }, // Asegúrate de que en desarrollo no esté en secure, sólo en producción
  store: redisStore,
})

on login i am req.session.test = “test”

and am console log my output

app.use((req, res, next) => {
  next()
  console.warn('TEST1 session from index backend', req.session)
})

i repeat, on localhost it works.

NOTE: My domain name is not the same on my backend and my front end. but

Do you have REDIS_URL defined on the Render Dashboard in your Web Service?

ofcourse

I have the same issue, my setup works on localhost too :frowning:
Did you find a solution to this?