Merge pull request #16 from kyuno053/fix/web-api-base-url-same-origin

fix(web): l'API n'appelait pas la bonne origine en prod
This commit is contained in:
kyuno053 2026-08-17 23:30:54 +02:00 committed by GitHub
commit 9d19136c93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -12,8 +12,16 @@ import {
type ThemePreference, type ThemePreference,
} from "@batch-cooking/shared"; } 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 * Thrown by {@link ApiClient} whenever the API responds with a non-2xx