fix: persist login sessions across browser restarts

This commit is contained in:
Codex committed 2026-11-08 20:32:03 +00:00
1 parent 91f57879fb
commit 6593319c87
2 files changed
+96 -3

No files matched your search

+10 -3
View File
@@ -165,13 +165,12 @@ passport.deserializeUser(async (id: string, done) => {
}
});
export function initSession() {
const redisClient = createClient({
export function initSession(redisClient = createClient({
socket: {
port: config.REDIS_PORT,
host: config.REDIS_HOSTNAME,
},
});
})) {
redisClient.on("error", (err) =>
logger.error("redis client error", serializeError(err))
);
@@ -186,6 +185,14 @@ export function initSession() {
store: redisStore,
saveUninitialized: false,
resave: false,
rolling: true,
cookie: {
// Keep the browser cookie and Redis expiry aligned on active sessions.
maxAge: 30 * 24 * 60 * 60 * 1000,
httpOnly: true,
sameSite: "lax",
secure: "auto",
},
});
}