Hi guys im trying to have my session persist using connect-redis but I haven't had any success yet.
libraries im using
import connectRedis from "connect-redis";
import Redis from "ioredis";
const app = express();
const RedisStore = connectRedis(session);
const redis = new Redis();
app
.use(morgan("dev"))
.use(
cors({
origin: "http://localhost:3000",
credentials: true,
})
)
.use(bodyParser.urlencoded({ extended: false }))
.use(bodyParser.json())
.use(
session({
name: COOKIE_NAME,
store: new RedisStore({
client: redis,
disableTouch: true,
logErrors: true,
}),
secret: SESSION_SECRET,
saveUninitialized: false,
resave: false,
cookie: {
secure: false,
maxAge: 1000 * 60 * 60 * 24,
httpOnly: false,
sameSite: "lax",
},
})
);
My authentication works properly. However, the session is deleted on refresh.
Here is my 'response headers'
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://localhost:3000
Connection: keep-alive
Content-Length: 205
Content-Type: application/json; charset=utf-8
Date: Mon, 01 Mar 2021 22:08:09 GMT
ETag: W/"cd-dAeR9gw/rPjK0kUvyLV0BaIadT4"
Set-Cookie: qid=s%3ADozy85MX9RpXrf7FSGEoD-CdlN4LMY8a.0qK2D0Hjz%2B8wIRMaxeMUhKCRQwmRPQrULYSTVW5xo1g; Path=/; Expires=Tue, 02 Mar 2021 22:08:09 GMT; SameSite=Lax
Vary: Origin
X-Powered-By: Express
However the cookie is not being set.
Would love any advice
EDIT: added response header response