RAGELITE / frontend /src /api /client.ts
triflix
initial: automAIta boilerplate (FastAPI + React PWA, single-port HF Space)
a6229e1
raw
history blame contribute delete
704 Bytes
// In dev, Vite proxies /api → http://localhost:8000.
// In the built container, FastAPI serves both /api and the static SPA.
// So same-origin everywhere — no base URL needed.
const BASE = "";
export async function apiGet<T>(path: string, init?: RequestInit): Promise<T> {
const res = await fetch(`${BASE}${path}`, {
...init,
headers: { Accept: "application/json", ...(init?.headers ?? {}) },
});
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
return (await res.json()) as T;
}
export interface StatusResponse {
status: string;
app: string;
version: string;
uptime_seconds: number;
}
export const getStatus = () => apiGet<StatusResponse>("/api/status");