store sessions in the DB

This commit is contained in:
Dobromir Popov
2026-07-07 22:13:12 +03:00
parent dae0719a32
commit a0b37ad1b9
5 changed files with 176 additions and 34 deletions

View File

@@ -224,6 +224,7 @@
<section data-tab="overview"><h2>Model usage (RPM)</h2><div id="stats" class="empty">loading…</div></section>
<section data-tab="overview" class="wide"><h2>Call wall</h2><div id="call-wall" class="empty">loading...</div></section>
<section data-tab="chat" class="wide chat-section">
<h2 style="display:none">Chat / inference</h2>
<div class="chat-app">
<aside class="chat-sidebar">
<button type="button" class="chat-new-btn" onclick="createNewChatSession()">+ New chat</button>
@@ -273,7 +274,7 @@ async function fetchJson(path) {
const headers = {};
const token = localStorage.getItem("meshnet_session");
if (token) headers["Authorization"] = "Bearer " + token;
const r = await fetch(path, { headers });
const r = await fetch(path, { headers, credentials: "same-origin" });
if (!r.ok) return null;
return await r.json();
} catch { return null; }
@@ -1029,6 +1030,7 @@ async function apiCall(path, method, body, bearerToken) {
const r = await fetch(path, {
method: method || "GET",
headers,
credentials: "same-origin",
body: body ? JSON.stringify(body) : undefined,
});
const data = await r.json().catch(() => ({}));
@@ -1371,7 +1373,7 @@ renderChatModels();
renderChatHistory();
renderChatAuthHint();
setInterval(refresh, 4000);
setInterval(() => { if (sessionToken) renderAccountPanel(); }, 8000);
setInterval(() => { if (sessionToken || isLoggedIn) renderAccountPanel(); }, 8000);
</script>
</body>
</html>