feat: add enterprise identity and channel integrations

This commit is contained in:
hailin
2026-07-27 19:03:42 +08:00
parent d93cb75c10
commit e69368a2f3
44 changed files with 5045 additions and 69 deletions

View File

@@ -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