Installer: .env-Hinweis + Beispiel-.env + Backend-Health-Check; freundlichere API-Fehler
- install.sh: ensure_example legt .env.example an falls fehlend; env_hint weist klar auf die anpassbare .env hin; wait_for_backend pollt /api/health und meldet 502-Ursachen mit Log-Hinweis. - web/api.js: HTML-Fehlerseiten (z.B. nginx 502) nicht mehr roh anzeigen, stattdessen verständliche Meldung. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -49,14 +49,22 @@ async function request(path, { method = "GET", body, form } = {}) {
|
||||
}
|
||||
|
||||
if (!resp.ok) {
|
||||
const detail =
|
||||
(data && data.detail) ||
|
||||
(typeof data === "string" ? data : null) ||
|
||||
`Fehler ${resp.status}`;
|
||||
throw new ApiError(
|
||||
Array.isArray(detail) ? detail.map((d) => d.msg).join(", ") : detail,
|
||||
resp.status
|
||||
);
|
||||
let detail;
|
||||
if (data && data.detail) {
|
||||
detail = Array.isArray(data.detail)
|
||||
? data.detail.map((d) => d.msg).join(", ")
|
||||
: data.detail;
|
||||
} else if (resp.status === 502 || resp.status === 503 || resp.status === 504) {
|
||||
detail = `Server nicht erreichbar (${resp.status}). Läuft der Backend-Dienst? Prüfe: docker compose logs backend`;
|
||||
} else if (typeof data === "string" && data.trim().startsWith("<")) {
|
||||
// HTML-Fehlerseite (z.B. von nginx) nicht roh anzeigen
|
||||
detail = `Server-Fehler (${resp.status}).`;
|
||||
} else if (typeof data === "string" && data) {
|
||||
detail = data;
|
||||
} else {
|
||||
detail = `Fehler ${resp.status}`;
|
||||
}
|
||||
throw new ApiError(detail, resp.status);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user