File tree Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,20 @@ 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_ORIGINS : z . string ( ) . optional ( ) , // Trusted origins, useful for React Native
15+ AUTH_TRUSTED_ORIGINS : z
16+ . string ( )
17+ . optional ( )
18+ . transform ( ( stringValue ) => stringValue ?. split ( ',' ) )
19+ . transform ( ( values ) => [
20+ ...( values ?. map ( ( v ) => v . trim ( ) ) ?? [ ] ) ,
21+ // Setup vercel urls as trusted origins
22+ ...( process . env . VERCEL_URL
23+ ? [ `https://${ process . env . VERCEL_URL } ` ]
24+ : [ ] ) ,
25+ ...( process . env . VERCEL_BRANCH_URL
26+ ? [ `https://${ process . env . VERCEL_BRANCH_URL } ` ]
27+ : [ ] ) ,
28+ ] ) ,
1629
1730 GITHUB_CLIENT_ID : zOptionalWithReplaceMe ( ) ,
1831 GITHUB_CLIENT_SECRET : zOptionalWithReplaceMe ( ) ,
Original file line number Diff line number Diff line change @@ -25,18 +25,7 @@ export const auth = betterAuth({
2525 expiresIn : envServer . SESSION_EXPIRATION_IN_SECONDS ,
2626 updateAge : envServer . SESSION_UPDATE_AGE_IN_SECONDS ,
2727 } ,
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- ] ,
28+ trustedOrigins : envServer . AUTH_TRUSTED_ORIGINS ,
4029 database : prismaAdapter ( db , {
4130 provider : 'postgresql' ,
4231 } ) ,
You can’t perform that action at this time.
0 commit comments