beuaah
This commit is contained in:
parent
0fb4513b4b
commit
0114214995
2 changed files with 5 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue