fix: persist admin sessions across restart

This commit is contained in:
Андрей Бобырев
2026-06-06 15:44:45 +03:00
parent 76201b6b2a
commit caee0b4cff
3 changed files with 30 additions and 5 deletions

View File

@@ -636,6 +636,10 @@ async function api(path, options = {}) {
if (options.body && !headers["Content-Type"]) headers["Content-Type"] = "application/json";
const res = await fetch(path, { ...options, headers, credentials: "same-origin" });
const data = await res.json().catch(() => ({}));
if (res.status === 401) {
window.location.assign("/");
throw new Error("unauthorized");
}
if (!res.ok || data.ok === false) throw new Error(data.error || `HTTP ${res.status}`);
return data.data ?? data;
}

View File

@@ -11,7 +11,7 @@
document.documentElement.dataset.theme = theme;
}());
</script>
<link rel="stylesheet" href="/styles.css?v=2.5.0-admin25">
<link rel="stylesheet" href="/styles.css?v=2.5.0-admin26">
</head>
<body>
<div class="app-shell">
@@ -482,6 +482,6 @@
<button id="qrCopyBtn" type="button" class="soft" data-i18n="copyLink">Copy link</button>
</div>
</div>
<script src="/app.js?v=2.5.0-admin25" type="module"></script>
<script src="/app.js?v=2.5.0-admin26" type="module"></script>
</body>
</html>