@@ -6,7 +6,7 @@ import { createAuthMiddleware, openAPI } from "better-auth/plugins";
66import { createDb } from "../../drizzle/client.js" ;
77import { authSchema , storageSchema } from "@repo/rdb/schema" ;
88
9- const db = createDb ( { databaseUrl : process . env . DATABASE_URL , } )
9+ const db = createDb ( { databaseUrl : process . env . DATABASE_URL } ) ;
1010
1111export const auth = betterAuth ( {
1212 databaseHooks : {
@@ -41,13 +41,13 @@ export const auth = betterAuth({
4141 itemType : "folder" ,
4242 } )
4343 . returning ( ) ;
44- } )
45- }
46- }
47- }
44+ } ) ;
45+ } ,
46+ } ,
47+ } ,
4848 } ,
49- baseURL : "http://localhost:3000/ auth" ,
50- trustedOrigins : [ "http://localhost:3000" , "http://[::1]:3000" ] ,
49+ baseURL : ` ${ process . env . ACCESS_CONTROL_ALLOW_ORIGIN ! } :80/ auth` ,
50+ trustedOrigins : [ ` ${ process . env . ACCESS_CONTROL_ALLOW_ORIGIN ! } :80` ] ,
5151 advanced : {
5252 defaultCookieAttributes : {
5353 sameSite : "lax" ,
@@ -72,7 +72,7 @@ export const auth = betterAuth({
7272 {
7373 schema : authSchema ,
7474 provider : "pg" ,
75- debugLogs : true
75+ debugLogs : true ,
7676 }
7777 ) ,
7878 emailAndPassword : {
@@ -83,7 +83,7 @@ export const auth = betterAuth({
8383 enabled : true ,
8484 clientId : process . env . GOOGLE_CLIENT_ID as string ,
8585 clientSecret : process . env . GOOGLE_CLIENT_SECRET as string ,
86- redirectURI : "http://localhost: 20257/api/auth/callback/google" ,
86+ redirectURI : ` ${ process . env . API_BASE_URL ! } : 20257/api/auth/callback/google` ,
8787 accessType : "offline" ,
8888 prompt : "select_account" ,
8989 } ,
@@ -119,7 +119,7 @@ export const betterAuthMiddleware = new Elysia({ name: "better-auth" })
119119 . all ( "/api/auth/*" , async ( context : Context ) => {
120120 if ( [ "POST" , "GET" ] . includes ( context . request . method ) ) {
121121 const response = await auth . handler ( context . request ) ;
122-
122+
123123 console . log ( response ) ;
124124 // If it's a redirect response, make sure to return it properly
125125 if ( response && response . status >= 300 && response . status < 400 ) {
@@ -171,4 +171,4 @@ export const betterAuthMiddleware = new Elysia({ name: "better-auth" })
171171 } ;
172172 } ,
173173 } ) ,
174- } ) ;
174+ } ) ;
0 commit comments