This commit is contained in:
Guillem George 2026-05-15 20:13:34 +02:00
parent 0fb4513b4b
commit 0114214995
2 changed files with 5 additions and 3 deletions

View file

@ -136,16 +136,17 @@ async function authedAPIRequest(endpoint, options) {
if (!options.method) {
console.error("Invalid parameter: options (missing method)");
return null
}
if (!options.headers) {
options.headers = {};
}
options.headers.Authorization = localStorage.getItem("token");
options.headers.Authorization = "Bearer " + localStorage.getItem("token");
options.mode = "cors";
const full_endpoint = import.meta.env.VITE_URL + endpoint;
const full_endpoint = import.meta.env.VITE_URL + "/api" + endpoint;
let response;
try {
@ -163,6 +164,7 @@ async function authedAPIRequest(endpoint, options) {
}
localStorage.clear();
alert("Redirecting to logging page")
redirect.redirectToLoginPage();
return null;
}