fix: stop aggressive API polling and SSE reconnect when auth lost
When unauthenticated (TOTP gate active), the dashboard was polling /api/v1/services/status every few seconds and reconnecting SSE every 2-8s indefinitely. Now: 401/403 sets _dcAuthLost flag to skip the polling interval, and SSE stops after 5 consecutive failures.
This commit is contained in:
@@ -401,9 +401,15 @@
|
||||
refreshInFlight = (async () => {
|
||||
try {
|
||||
const response = await fetch('/api/v1/services/status', { cache: 'no-store' });
|
||||
if (response.status === 401 || response.status === 403) {
|
||||
// Auth lost — stop the polling loop from hammering every few seconds
|
||||
window._dcAuthLost = true;
|
||||
throw new Error(`Authentication required (${response.status})`);
|
||||
}
|
||||
if (!response.ok) {
|
||||
throw new Error(`Status refresh failed (${response.status})`);
|
||||
}
|
||||
window._dcAuthLost = false; // auth working again
|
||||
const data = await response.json();
|
||||
applyBatchResults(data.statuses || {});
|
||||
updateStamp('last check', data.checkedAt || new Date());
|
||||
|
||||
Reference in New Issue
Block a user