Skip to content

Commit

Permalink
Fix session cookie not being set in HTTPS
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Evans <ebrian101@gmail.com>
  • Loading branch information
mrbrianevans committed Oct 18, 2024
1 parent 119e154 commit b08ba5e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {serverLogTransport} from '../backend-shared/loggers.js'
import RedisStore from 'connect-redis'
const port = parseInt(process.env.PORT??'4004')

const fastify = Fastify({logger: {stream: serverLogTransport, level: 'trace'}})
const fastify = Fastify({logger: {stream: serverLogTransport, level: 'trace'}, trustProxy: true})

//register any third party plugins here
{
Expand All @@ -15,7 +15,8 @@ const fastify = Fastify({logger: {stream: serverLogTransport, level: 'trace'}})
secret: getEnv('SESSION_SECRET'),
cookie: {
secure: getEnv('SITE_ADDRESS').startsWith('https'),
maxAge: 86400_000*30
maxAge: 86400_000*30,
sameSite: 'lax'
},
saveUninitialized: false,
// set store to Redis so that sessions are persisted after server restarts
Expand Down

0 comments on commit b08ba5e

Please sign in to comment.