From 01142149955624b5fa8cf12f05bf3cad584b7756 Mon Sep 17 00:00:00 2001 From: Guillem George Date: Fri, 15 May 2026 20:13:34 +0200 Subject: [PATCH] beuaah --- src/pages/debug/utils.js | 2 +- src/utils/auth.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/debug/utils.js b/src/pages/debug/utils.js index fa74b1c..d96fcc8 100644 --- a/src/pages/debug/utils.js +++ b/src/pages/debug/utils.js @@ -10,7 +10,7 @@ export async function displayStudentProfile() { const _uid = decoded.uid; // You have to write a request to fetch your informations - // const request_result = authedAPIRequest(`/api/students/${_uid}`, {method: "GET"}); + const request_result = await authedAPIRequest(`/students/${_uid}`, {method: "GET"}); if (request_result === null) { createAlert( diff --git a/src/utils/auth.js b/src/utils/auth.js index a012f5e..76165af 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -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; }