feat: Implement initial with admin and mobile clients, authentication, data models, and lead generation scripts.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { createAuthClient } from 'better-auth/react'
|
||||
import { magicLinkClient } from 'better-auth/client/plugins'
|
||||
import Constants from 'expo-constants'
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage'
|
||||
|
||||
const apiUrl =
|
||||
Constants.expoConfig?.extra?.apiUrl ??
|
||||
@@ -10,4 +11,15 @@ const apiUrl =
|
||||
export const authClient = createAuthClient({
|
||||
baseURL: apiUrl,
|
||||
plugins: [magicLinkClient()],
|
||||
fetchOptions: {
|
||||
customFetchImpl: async (url, options) => {
|
||||
const token = await AsyncStorage.getItem('better-auth-session')
|
||||
const headers = new Headers((options?.headers as HeadersInit) ?? {})
|
||||
headers.set('origin', apiUrl)
|
||||
if (token) {
|
||||
headers.set('cookie', `better-auth.session_token=${token}`)
|
||||
}
|
||||
return fetch(url, { ...options, headers })
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user