From ec22c857d54b6c1b08c74546e861f2b6b0ee7d87 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Thu, 13 Nov 2025 17:20:31 +0100 Subject: [PATCH] Update api-config.ts --- AppImage/lib/api-config.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/AppImage/lib/api-config.ts b/AppImage/lib/api-config.ts index 63e8a66..0a2f266 100644 --- a/AppImage/lib/api-config.ts +++ b/AppImage/lib/api-config.ts @@ -69,7 +69,9 @@ export function getAuthToken(): string | null { if (typeof window === "undefined") { return null } - return localStorage.getItem("proxmenux-auth-token") + const token = localStorage.getItem("proxmenux-auth-token") + console.log("[v0] getAuthToken:", token ? `Token found (${token.substring(0, 20)}...)` : "No token found") + return token } /** @@ -91,14 +93,21 @@ export async function fetchApi(endpoint: string, options?: RequestInit): Prom if (token) { headers["Authorization"] = `Bearer ${token}` + console.log("[v0] fetchApi: Adding Authorization header to request:", endpoint) + } else { + console.log("[v0] fetchApi: No token available for request:", endpoint) } + console.log("[v0] fetchApi: Fetching", url, "with headers:", Object.keys(headers)) + const response = await fetch(url, { ...options, headers, cache: "no-store", }) + console.log("[v0] fetchApi: Response status for", endpoint, ":", response.status) + if (!response.ok) { throw new Error(`API request failed: ${response.status} ${response.statusText}`) }