File tree Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ DATABASE_URL="postgres://${DOCKER_DATABASE_USERNAME}:${DOCKER_DATABASE_PASSWORD}
2323BETTER_AUTH_SECRET = " REPLACE ME" # You can use `npx @better-auth/cli@latest secret` to a generated secret
2424SESSION_EXPIRATION_IN_SECONDS = 2592000 # 30 days
2525SESSION_UPDATE_AGE_IN_SECONDS = 86400 # 1 day (every 1 day the session expiration is updated)
26- AUTH_TRUSTED_ORIGIN = " start-ui-native://,start-ui-native://*" # Mobile app scheme for trustedOrigins config
26+ AUTH_TRUSTED_ORIGINS = " start-ui-native://,start-ui-native://*" # Mobile app scheme for trustedOrigins config
2727
2828# GITHUB
2929GITHUB_CLIENT_ID = " REPLACE ME"
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ export const envServer = createEnv({
1212 BETTER_AUTH_SECRET : z . string ( ) ,
1313 SESSION_EXPIRATION_IN_SECONDS : z . coerce . number ( ) . int ( ) . prefault ( 2592000 ) , // 30 days by default
1414 SESSION_UPDATE_AGE_IN_SECONDS : z . coerce . number ( ) . int ( ) . prefault ( 86400 ) , // 1 day by default
15- AUTH_TRUSTED_ORIGIN : z . string ( ) . optional ( ) ,
15+ AUTH_TRUSTED_ORIGINS : z . string ( ) . optional ( ) , // Trusted origins, useful for React Native
1616
1717 GITHUB_CLIENT_ID : zOptionalWithReplaceMe ( ) ,
1818 GITHUB_CLIENT_SECRET : zOptionalWithReplaceMe ( ) ,
Original file line number Diff line number Diff line change @@ -25,10 +25,18 @@ export const auth = betterAuth({
2525 expiresIn : envServer . SESSION_EXPIRATION_IN_SECONDS ,
2626 updateAge : envServer . SESSION_UPDATE_AGE_IN_SECONDS ,
2727 } ,
28- // Allows an Expo native app to use social auth, can be delete if no needed
29- trustedOrigins : envServer . AUTH_TRUSTED_ORIGIN
30- ? envServer . AUTH_TRUSTED_ORIGIN . split ( ',' )
31- : undefined ,
28+ trustedOrigins : [
29+ // Setup custom trusted origins, useful for React Native
30+ ...( envServer . AUTH_TRUSTED_ORIGINS
31+ ? envServer . AUTH_TRUSTED_ORIGINS . split ( ',' )
32+ : [ ] ) ,
33+
34+ // Setup vercel urls as trusted origins
35+ // eslint-disable-next-line no-process-env
36+ ...( process . env . VERCEL_URL ? [ process . env . VERCEL_URL ] : [ ] ) ,
37+ // eslint-disable-next-line no-process-env
38+ ...( process . env . VERCEL_BRANCH_URL ? [ process . env . VERCEL_BRANCH_URL ] : [ ] ) ,
39+ ] ,
3240 database : prismaAdapter ( db , {
3341 provider : 'postgresql' ,
3442 } ) ,
You can’t perform that action at this time.
0 commit comments