// frontend/src/api.ts export async function api(path: string, init?: RequestInit): Promise { const r = await fetch(path, { credentials:'include', ...init }); if (!r.ok) throw new Error(await r.text()); const ct = r.headers.get('content-type') || ''; return (ct.includes('json') ? r.json() : (r.text() as any)) as T; } export type WhoAmI = { username: string; root: string };