From d81168b7a91ee45604c1c72f1b254fd8d5991256 Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Wed, 29 Jul 2026 15:33:07 +0200 Subject: [PATCH] Aligns mock API_BASE with the real ApiClient's origin fallback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mocks re-derived VITE_API_BASE_URL with their own fallback instead of reusing getAppConfig().apiBaseUrl, so the two silently diverged whenever the env var was unset (as in CI, where no local .env.local is present) — every MSW-intercepted request then had no matching handler. --- frontend/src/mocks/auth/fixtures.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/src/mocks/auth/fixtures.ts b/frontend/src/mocks/auth/fixtures.ts index 9899e8c..445c262 100644 --- a/frontend/src/mocks/auth/fixtures.ts +++ b/frontend/src/mocks/auth/fixtures.ts @@ -1,7 +1,14 @@ import type { AuthResponse, User } from '@/api/types'; +import { getAppConfig } from '@/lib/config'; -/** Base URL the ApiClient targets; mocks must match the absolute URL. */ -export const API_BASE = import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:5000'; +/** + * Base URL the ApiClient targets; mocks must match it exactly. Reads the same + * getAppConfig().apiBaseUrl the real ApiClient is constructed with, rather than + * re-deriving VITE_API_BASE_URL with its own fallback — a second, diverging default here + * previously matched the real client's origin only when a local .env.local happened to set + * VITE_API_BASE_URL, and silently mismatched (all mocks unmatched) whenever it was unset, as in CI. + */ +export const API_BASE = getAppConfig().apiBaseUrl; export const TEST_CREDENTIALS = { email: 'owner@example.com',