Skip to content

Commit 089f533

Browse files
committed
fix: auth cookie expiring too early
When not set in an environment variable, `COOKIE_EXPIRES_IN` will default to `60 * 60 * 24 * 7` = 604,800s = 7 days, since the `Max-Age` cookie attribute is specified in seconds: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#max-agenumber However, the `res.cookie` function takes the `maxAge` **in milliseconds**. which means that the previous amount of seconds actually meant *604.8 seconds* ~= 10 minutes. Oof.
1 parent ad199fa commit 089f533

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

server/src/auth/auth.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ export class AuthService {
239239

240240
const frontEndURL = this.FRONTEND_URL;
241241
const domain = this.APP_DOMAIN;
242-
const maxAge = parseInt(this.COOKIE_EXPIRES_IN);
242+
const maxAge = parseInt(this.COOKIE_EXPIRES_IN) * 1000;
243243

244244
res.cookie('token', token.access_token, {
245245
domain: domain,

0 commit comments

Comments
 (0)