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:
commit
9d19136c93
1 changed files with 10 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue