Skip to content

Commit

Permalink
specify cookie max age + session expiry
Browse files Browse the repository at this point in the history
  • Loading branch information
emallson committed May 3, 2024
1 parent 2ebf34d commit 6c61409
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@fastify/cors": "^8.5.0",
"@fastify/passport": "^2.4.0",
"@fastify/reply-from": "^9.7.0",
"@fastify/secure-session": "^7.3.0",
"@fastify/secure-session": "^7.5.1",
"@sentry/node": "^7.76.0",
"axios": "^1.6.0",
"date-fns": "^2.30.0",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ const app = Fastify({
logger: true,
});

const SESSION_DURATION = 365 * 24 * 60 * 60;

app.register(secureSession, {
key:
process.env.NODE_ENV === "development"
? fs.readFileSync(path.join(__dirname, "../.secret-key.development"))
: fs.readFileSync(path.join(__dirname, "../secret-key")),
expiry: SESSION_DURATION,
cookie: {
path: "/",
maxAge: SESSION_DURATION,
},
});
app.register(cors, {
Expand Down

0 comments on commit 6c61409

Please sign in to comment.