10 lines
442 B
TypeScript
10 lines
442 B
TypeScript
import { ApiClient } from './client'
|
|
import { session } from '../auth/session'
|
|
import { createAuthRefresh } from '../auth/refresh'
|
|
|
|
const baseUrl = import.meta.env.VITE_API_BASE_URL || 'http://127.0.0.1:8000/api/v1'
|
|
|
|
const normalizedBaseUrl = baseUrl.replace(/\/$/, '')
|
|
export const refreshAuth = createAuthRefresh(normalizedBaseUrl)
|
|
export const api = new ApiClient(normalizedBaseUrl, () => session.get()?.access_token || null, refreshAuth)
|