// frontend/src/lib/api.ts // ✅ DEV: immer relativ, damit Vite-Proxy (/api -> :9999) greift → kein CORS // ✅ PROD: optional per VITE_API_BASE überschreiben const API_BASE = import.meta.env.VITE_API_BASE ?? (import.meta.env.DEV ? '' : '') export const apiUrl = (path: string) => { const p = path.startsWith('/') ? path : `/${path}` return `${API_BASE}${p}` } export async function apiFetch(path: string, init?: RequestInit) { return fetch(apiUrl(path), { ...init, // falls du Cookies/Sessions brauchst: credentials: 'include', }) }