Keep API not-found and 401 responses usable behind Ingress and in the Web UI.

Return native JSON with the missing id in the message, clear stale sessions on
401, and document ingress-nginx annotations so branded HTML 404/405 pages do
not rewrite simulator bodies.
This commit is contained in:
2026-07-22 06:52:35 +03:00
parent 131e2e63d2
commit e8b08526d1
13 changed files with 260 additions and 62 deletions
+27 -9
View File
@@ -6228,6 +6228,21 @@
}
}
async function clearSession(options = {}) {
const { toastMessage = null, toastKind = "info", closePanel = true } = options;
state.ticket = null;
state.csrf = null;
state.username = null;
document.cookie = "vmware-api-session-id=; Max-Age=0; path=/; SameSite=Strict";
try { localStorage.removeItem(LS_AUTH); } catch { /* ignore */ }
try { sessionStorage.removeItem(LS_AUTH); } catch { /* ignore */ }
setAuth(false);
persistAuth();
if (closePanel) closeAuthPanel();
resetClusterStats("—");
if (toastMessage) toast(toastMessage, toastKind);
}
async function logout() {
try {
if (state.ticket) {
@@ -6240,15 +6255,15 @@
} catch (error) {
console.warn(error);
}
state.ticket = null;
state.csrf = null;
state.username = null;
document.cookie = "vmware-api-session-id=; Max-Age=0; path=/; SameSite=Strict";
setAuth(false);
persistAuth();
closeAuthPanel();
resetClusterStats("—");
toast("Signed out", "info");
clearSession({ toastMessage: "Signed out", toastKind: "info" });
}
function expireSession() {
clearSession({
toastMessage: "Session expired — sign in again",
toastKind: "warn",
closePanel: false,
});
}
function updateStatusBadge(status) {
@@ -6340,6 +6355,9 @@
const text = await res.text();
let parsed;
try { parsed = JSON.parse(text); } catch { parsed = text; }
if (res.status === 401 && (state.ticket || state.username)) {
expireSession();
}
return { status: res.status, body: parsed, durationMs: Math.round(performance.now() - started) };
}