diff --git a/apps/web/src/api/client.ts b/apps/web/src/api/client.ts index 3080d05..408ecbc 100644 --- a/apps/web/src/api/client.ts +++ b/apps/web/src/api/client.ts @@ -12,8 +12,16 @@ import { type ThemePreference, } from "@batch-cooking/shared"; -/** Base URL of the API, configurable via `VITE_API_URL` (see `.env.example`). */ -const API_BASE_URL: string = import.meta.env.VITE_API_URL ?? "http://localhost:3000"; +/** + * Base URL of the API, configurable via `VITE_API_URL` (see `.env.example`). + * Defaults to `""` (same origin as the page) — correct for the production + * Docker image, where the API serves this very frontend build (see + * apps/api/Dockerfile), so a relative path already reaches it. Native dev + * (`pnpm dev:web`) overrides this via `VITE_API_URL=http://localhost:3000` + * in `apps/web/.env`, since the Vite dev server (5173) and the API (3000) + * are on different origins there. + */ +const API_BASE_URL: string = import.meta.env.VITE_API_URL ?? ""; /** * Thrown by {@link ApiClient} whenever the API responds with a non-2xx