feat: add enterprise identity and channel integrations
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL ?? '/api'
|
||||
|
||||
export function apiUrl(path: string) {
|
||||
return `${API_BASE_URL}${path}`
|
||||
}
|
||||
|
||||
let csrfToken: string | null = null
|
||||
|
||||
export class ApiError extends Error {
|
||||
@@ -29,7 +33,7 @@ async function readError(response: Response) {
|
||||
|
||||
async function getCsrfToken() {
|
||||
if (!csrfToken) {
|
||||
const response = await fetch(`${API_BASE_URL}/accounts/auth/csrf`, {
|
||||
const response = await fetch(apiUrl('/accounts/auth/csrf'), {
|
||||
credentials: 'include'
|
||||
})
|
||||
if (!response.ok) {
|
||||
@@ -51,7 +55,7 @@ export async function apiRequest<T>(path: string, init?: RequestInit): Promise<T
|
||||
headers.set('x-csrftoken', await getCsrfToken())
|
||||
}
|
||||
|
||||
const response = await fetch(`${API_BASE_URL}${path}`, {
|
||||
const response = await fetch(apiUrl(path), {
|
||||
...init,
|
||||
credentials: 'include',
|
||||
headers
|
||||
|
||||
Reference in New Issue
Block a user