diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index 5f73f0e..eb5be3f 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -52,14 +52,23 @@ async function apiRequest( const url = `${baseUrl}${cleanEndpoint}`; console.log(`[API Request] ${url}`); // Debug log - const res = await fetch(url, { - ...options, - headers: { - "Content-Type": "application/json", - ...(token && { Authorization: `Bearer ${token}` }), - ...options.headers, - }, - }); + const controller = new AbortController(); + const timeout = setTimeout(() => controller.abort(), 15000); + + let res: Response; + try { + res = await fetch(url, { + ...options, + signal: controller.signal, + headers: { + "Content-Type": "application/json", + ...(token && { Authorization: `Bearer ${token}` }), + ...options.headers, + }, + }); + } finally { + clearTimeout(timeout); + } if (!res.ok) { const error = await res.text();