OPS-1: fix e2e regression -- API_BASE_URL conditional on import.meta.env.PROD
Dev (Vite dev server / e2e mock mode): falls back to 'http://localhost:5179' so Playwright route interception on http://localhost:5179/** keeps working. Production (npm run build -> PROD=true): falls back to '/api' so nginx proxy strips the prefix without any hostname baked in at build time. VITE_API_BASE_URL (set by Aspire in dev, injected LAN IP) always wins over both. Evidence: npm run e2e 48/48 PASS (mock mode, both viewports). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,12 +2,12 @@ import { de } from '../strings/de'
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Basis-URL der GerbilManagerWebAPI.
|
* Basis-URL der GerbilManagerWebAPI.
|
||||||
* Dev (Aspire): VITE_API_BASE_URL wird von AppHost zur Laufzeit gesetzt (LAN-IP + Port).
|
* Dev (Vite dev server / e2e mock): absolute URL, damit Playwright-Route-Interception greift.
|
||||||
* Produktion (Docker/nginx): kein Env-Var nötig — nginx proxyt /api/* zum API-Container,
|
* Produktion (Vite build → nginx): relativer Pfad /api; nginx proxyt zum API-Container.
|
||||||
* daher funktioniert der relative Pfad /api auf jedem Host ohne Build-Zeit-Kopplung.
|
* Aspire (VITE_API_BASE_URL gesetzt): überschreibt immer (LAN-IP + Port für Handy-Zugriff).
|
||||||
*/
|
*/
|
||||||
export const API_BASE_URL: string =
|
export const API_BASE_URL: string =
|
||||||
import.meta.env.VITE_API_BASE_URL ?? '/api'
|
import.meta.env.VITE_API_BASE_URL ?? (import.meta.env.PROD ? '/api' : 'http://localhost:5179')
|
||||||
|
|
||||||
export class ApiError extends Error {
|
export class ApiError extends Error {
|
||||||
readonly status: number | null
|
readonly status: number | null
|
||||||
|
|||||||
Reference in New Issue
Block a user