feat(apiRequest): use JSON.parse for accessToken in Authorization header

The Authorization header in the apiRequest now utilizes JSON.parse for the accessToken. This change ensures proper parsing and retrieval of the item from the local storage when the window object is defined.
This commit is contained in:
Mathis H (Avnyr) 2024-06-20 14:55:23 +02:00
parent 0a239f4478
commit a2f2996ef9
Signed by: Mathis
GPG Key ID: DD9E0666A747D126

View File

@ -10,7 +10,7 @@ const AxiosConfigs = {
return {
headers: {
"content-type": "application/json",
Authorization: `Bearer ${typeof window !== "undefined" ? window.localStorage.getItem("sub") : "not-ssr"}`,
Authorization: `Bearer ${typeof window !== "undefined" ? JSON.parse(window.localStorage.getItem("sub") || "not-ssr") : "not-ssr"}`,
},
validateStatus: (status: number) => {
return status < 500; // Resolve only if the status code is less than 500