const API_BASE = (import.meta.env.VITE_API_BASE ?? "").trim().replace(/\/$/, ""); /** Resolve an API path. Empty base keeps same-origin relative paths for web `dist/`. */ export function apiUrl(path: string): string { if (!path.startsWith("/")) { throw new Error(`API path must start with /: ${path}`); } return API_BASE ? `${API_BASE}${path}` : path; } export function getApiBase(): string { return API_BASE; }