Skip to content

Commit 93de4bd

Browse files
committed
fix: update COOKIE_DOMAIN in .example.env for subdomain support and enhance cookie settings in authenticate function
1 parent f65c557 commit 93de4bd

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

.example.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ AUTH_JWT_SECRET=your-secret-whatever
2323
USER_AGENT=Podverse/API-2
2424

2525
# Use the public facing domain, not the internal docker network ip address.
26-
COOKIE_DOMAIN=localhost
26+
COOKIE_DOMAIN=localhost # prefix with a dot for subdomains, e.g. .podverse.fm or .beta.podverse.fm
2727
COOKIE_IS_SECURE=
2828

2929
#####

src/lib/auth/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export const authenticate = (req: Request, res: Response, next: NextFunction) =>
100100
res.cookie('jwt', token, {
101101
httpOnly: true,
102102
secure: process.env.NODE_ENV === 'production',
103+
...(config.api.cookie.domain !== 'localhost' ? { domain: config.api.cookie.domain } : {}),
103104
maxAge: 31536000000 // 1 year in milliseconds
104105
});
105106

0 commit comments

Comments
 (0)