Skip to content

Commit 071c006

Browse files
committed
fix: use env variable to set cookie domain
1 parent 9a24451 commit 071c006

4 files changed

Lines changed: 7 additions & 1 deletion

File tree

apps/backend/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ GOOGLE_CLIENT_ID=
44
GOOGLE_CLIENT_SECRET=
55
BETTER_AUTH_SECRET=
66
BETTER_AUTH_URL=http://localhost:3000 # Base URL of your app
7+
COOKIE_DOMAIN=

apps/backend/src/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const getEnv = (c: Context) => createEnv({
66
server: {
77
FRONTEND_URL: z.string().url(),
88
DB_FILE_NAME: z.string().url(),
9+
COOKIE_DOMAIN: z.string().url(),
910
BETTER_AUTH_SECRET: z.string(),
1011
BETTER_AUTH_URL: z.string().url(),
1112
GOOGLE_CLIENT_ID: z.string(),

apps/backend/src/lib/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const auth = (c: Context) => betterAuth({
2222
advanced: {
2323
crossSubDomainCookies: {
2424
enabled: true,
25-
domain: getEnv(c).FRONTEND_URL.replace(/^https?:\/\//, ''),
25+
domain: getEnv(c).COOKIE_DOMAIN,
2626
},
2727
},
2828
})

fly.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
app = 'periodos'
77
primary_region = 'hkg'
88

9+
[env]
10+
FRONTEND_URL = "https://periodos.nirjan.net"
11+
COOKIE_DOMAIN = "https://nirjan.net"
12+
913
[build]
1014

1115
[http_service]

0 commit comments

Comments
 (0)