fix: 401-401 retry on non-401, move login DOM bindings into page lifecycle, add abort support

This commit is contained in:
2026-07-27 19:46:30 +00:00
parent cc5679a1cd
commit e48ba72b81
3 changed files with 137 additions and 103 deletions
+7
View File
@@ -180,6 +180,13 @@ export async function apiFetch(url, options = {}) {
if (retryRes.ok) {
return { ok: json.ok, data: json.ok ? json.data : json, error: null, status: retryRes.status };
}
if (retryRes.status === 401) {
redirectLogin();
return { ok: false, data: null, error: 'Session expired', status: 401 };
}
if (!retryRes.ok) {
return { ok: false, data: null, error: json.error || `HTTP ${retryRes.status}`, status: retryRes.status };
}
}
redirectLogin();
return { ok: false, data: null, error: 'Session expired', status: 401 };