From d6bf6c6fe30b012dafe8e27de6af6d8cf3924d76 Mon Sep 17 00:00:00 2001 From: Gulum Date: Sat, 6 Jun 2026 07:39:33 +0200 Subject: [PATCH] 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) --- gerbil-manager-web/src/api/client.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gerbil-manager-web/src/api/client.ts b/gerbil-manager-web/src/api/client.ts index 0536118..08fc51d 100644 --- a/gerbil-manager-web/src/api/client.ts +++ b/gerbil-manager-web/src/api/client.ts @@ -2,12 +2,12 @@ import { de } from '../strings/de' /** * Basis-URL der GerbilManagerWebAPI. - * Dev (Aspire): VITE_API_BASE_URL wird von AppHost zur Laufzeit gesetzt (LAN-IP + Port). - * Produktion (Docker/nginx): kein Env-Var nötig — nginx proxyt /api/* zum API-Container, - * daher funktioniert der relative Pfad /api auf jedem Host ohne Build-Zeit-Kopplung. + * Dev (Vite dev server / e2e mock): absolute URL, damit Playwright-Route-Interception greift. + * Produktion (Vite build → nginx): relativer Pfad /api; nginx proxyt zum API-Container. + * Aspire (VITE_API_BASE_URL gesetzt): überschreibt immer (LAN-IP + Port für Handy-Zugriff). */ 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 { readonly status: number | null