diff --git a/apps/web/site/app.js b/apps/web/site/app.js index fe6b978..a6d2c5c 100644 --- a/apps/web/site/app.js +++ b/apps/web/site/app.js @@ -173,11 +173,19 @@ const MACRO_GENRES = [ ]; // --- API --- -async function apiGet(path) { +async function apiGet(path, timeoutMs = 15000) { const url = `${API_BASE}${path}`; - const r = await fetch(url, { mode: "cors" }); - if (!r.ok) throw new Error(`API ${path} failed: ${r.status}`); - return await r.json(); + // Timeout explicite : sans lui, une API qui ne répond jamais laisse l'UI (et + // le rechargement du viewport de la carte) bloquée indéfiniment. + const ctrl = new AbortController(); + const t = setTimeout(() => ctrl.abort(), timeoutMs); + try { + const r = await fetch(url, { mode: "cors", signal: ctrl.signal }); + if (!r.ok) throw new Error(`API ${path} failed: ${r.status}`); + return await r.json(); + } finally { + clearTimeout(t); + } } async function loadStats() { diff --git a/apps/web/site/index.html b/apps/web/site/index.html index 6c77e40..77bc599 100644 --- a/apps/web/site/index.html +++ b/apps/web/site/index.html @@ -11,26 +11,35 @@ - - + + - - - + + + - + - - + + - + - +