diff --git a/static/app.js b/static/app.js index d964102..a9c2cd5 100644 --- a/static/app.js +++ b/static/app.js @@ -1,5 +1,19 @@ 'use strict'; +// ── Auto-redirect on auth timeout ───────────────────────────────────── +// Intercept all fetch() calls: if the server returns 401 (auth expired), +// reload the page so Authelia redirects to the login screen. +(function () { + const _fetch = window.fetch; + window.fetch = async function (...args) { + const resp = await _fetch(...args); + if (resp.status === 401) { + window.location.reload(); + } + return resp; + }; +})(); + // ── Toast notifications — delegates to lt.toast from base.js ───────── function showToast(msg, type = 'success') { if (type === 'error') return lt.toast.error(msg);