mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
improvement: dynamically set better auth url based on env
This commit is contained in:
@@ -1,7 +1,25 @@
|
||||
import { emailOTPClient, genericOAuthClient } from 'better-auth/client/plugins'
|
||||
import { createAuthClient } from 'better-auth/react'
|
||||
|
||||
export function getBaseURL() {
|
||||
let baseURL
|
||||
|
||||
if (process.env.VERCEL_ENV === 'preview') {
|
||||
baseURL = `https://${process.env.VERCEL_URL}`
|
||||
} else if (process.env.VERCEL_ENV === 'development') {
|
||||
baseURL = `https://${process.env.VERCEL_URL}`
|
||||
} else if (process.env.VERCEL_ENV === 'production') {
|
||||
baseURL = process.env.BETTER_AUTH_URL
|
||||
} else if (process.env.NODE_ENV === 'development') {
|
||||
baseURL = process.env.BETTER_AUTH_URL
|
||||
}
|
||||
|
||||
console.log('baseURL:', baseURL)
|
||||
return baseURL
|
||||
}
|
||||
|
||||
export const client = createAuthClient({
|
||||
baseURL: getBaseURL(),
|
||||
plugins: [genericOAuthClient(), emailOTPClient()],
|
||||
})
|
||||
export const { useSession } = client
|
||||
|
||||
Reference in New Issue
Block a user