Add 401 redirect handling in frontend

JavaScript now checks for 401 status and redirects to login page when session expires.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Vadym Samoilenko 2026-03-11 21:53:18 +00:00
parent a6d1901fe5
commit 0a946ba2ac

View file

@ -270,6 +270,10 @@ function ensureTrailingEmpty() {
async function init() {
try {
var res = await fetch("/hm-ems-report/api/files");
if (res.status === 401) {
window.location.href = "/login";
return;
}
var files = await res.json();
var sel = document.getElementById("fileSelector");
@ -294,6 +298,10 @@ async function loadCampaign(filename) {
showLoading(true);
try {
var res = await fetch("/hm-ems-report/api/load/" + encodeURIComponent(filename));
if (res.status === 401) {
window.location.href = "/login";
return;
}
var payload = await res.json();
RAW_DATA = payload.data;