fix(storybook): disable logger network send in Storybook

Set VITE_STORYBOOK=true for storybook dev/build so the logger never
sends POST to /logs/frontend in the isolated UI environment. Prevents
94+ failed network requests in audit and keeps Storybook hermetic.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
senke 2026-02-05 12:16:23 +01:00
parent 7b1ec1fb12
commit bd8ef90ef6
3 changed files with 11 additions and 8 deletions

View file

@ -38,8 +38,8 @@
"qa:a11y": "make a11y",
"qa:all": "make qa-all",
"prepare": "husky",
"storybook": "cross-env VITE_API_URL=/api/v1 VITE_USE_MSW=true storybook dev -p 6006",
"build-storybook": "cross-env VITE_API_URL=/api/v1 VITE_USE_MSW=true storybook build"
"storybook": "cross-env VITE_API_URL=/api/v1 VITE_USE_MSW=true VITE_STORYBOOK=true storybook dev -p 6006",
"build-storybook": "cross-env VITE_API_URL=/api/v1 VITE_USE_MSW=true VITE_STORYBOOK=true storybook build"
},
"dependencies": {
"@dnd-kit/core": "^6.3.1",

View file

@ -94,12 +94,14 @@ function formatLog(
console.log(jsonLog);
// FIX #19: Envoi optionnel vers endpoint de logging (si configuré)
// Par défaut, utiliser l'endpoint backend si VITE_LOG_ENDPOINT n'est pas défini
const logEndpoint =
import.meta.env.VITE_LOG_ENDPOINT ||
(import.meta.env.VITE_API_URL
? `${import.meta.env.VITE_API_URL}/logs/frontend`
: null);
// Skip sending in Storybook so no network calls run in isolated UI environment
const isStorybook = import.meta.env.VITE_STORYBOOK === 'true';
const logEndpoint = isStorybook
? null
: (import.meta.env.VITE_LOG_ENDPOINT ||
(import.meta.env.VITE_API_URL
? `${import.meta.env.VITE_API_URL}/logs/frontend`
: null));
// Envoyer tous les logs (pas seulement les erreurs) vers le backend pour archivage
if (logEndpoint) {

View file

@ -8,6 +8,7 @@ interface ImportMetaEnv {
readonly VITE_APP_NAME: string;
readonly VITE_DEBUG: string;
readonly VITE_USE_MSW: string;
readonly VITE_STORYBOOK?: string;
readonly VITE_FCM_VAPID_KEY: string;
// more env variables...
}