ppt-tool/frontend/lib/apiFetch.ts
Vadym Samoilenko 1e00d480e2 Fix apiFetch: hardcode /ppt-tool basePath (publicRuntimeConfig broken in App Router)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 22:38:59 +00:00

13 lines
493 B
TypeScript

/**
* Wrapper around fetch that prepends the Next.js basePath so API calls
* reach the correct backend when deployed under a sub-path (/ppt-tool).
*
* Must match basePath in next.config.mjs.
* Usage: apiFetch('/api/v1/...', options) — identical to fetch(), just works.
*/
const BASE_PATH = '/ppt-tool';
export function apiFetch(path: string, init?: RequestInit): Promise<Response> {
const url = path.startsWith('/api/') ? `${BASE_PATH}${path}` : path;
return fetch(url, init);
}