vary express & express-session options depending on environment (fixes #21)

This commit is contained in:
Grant 2024-04-02 23:54:53 -06:00
parent cd62fc4f67
commit e09b78cf82
1 changed files with 10 additions and 1 deletions

View File

@ -16,8 +16,12 @@ export const session = expressSession({
prefix: process.env.REDIS_SESSION_PREFIX || "canvas_session:", prefix: process.env.REDIS_SESSION_PREFIX || "canvas_session:",
}), }),
cookie: { cookie: {
sameSite: "none",
httpOnly: false, httpOnly: false,
...(process.env.NODE_ENV === "development"
? { sameSite: "none" }
: {
secure: true,
}),
}, },
}); });
@ -27,6 +31,11 @@ export class ExpressServer {
constructor() { constructor() {
this.app = express(); this.app = express();
if (process.env.NODE_ENV === "production") {
this.app.set("trust proxy", 1);
}
this.httpServer = http.createServer(this.app); this.httpServer = http.createServer(this.app);
if (process.env.SERVE_CLIENT) { if (process.env.SERVE_CLIENT) {