From 3567c17bb10680e93f5bcbcb189a063aef577ccb Mon Sep 17 00:00:00 2001 From: Perplexity Bot Date: Tue, 4 Aug 2026 19:54:48 +0000 Subject: [PATCH] Revert inventory API to relative paths for Vite dev proxy --- frontend/src/lib/inventoryApi.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/frontend/src/lib/inventoryApi.ts b/frontend/src/lib/inventoryApi.ts index cfff45b..b1033fa 100644 --- a/frontend/src/lib/inventoryApi.ts +++ b/frontend/src/lib/inventoryApi.ts @@ -4,22 +4,20 @@ async function handleResponse(response: Response): Promise { if (!response.ok) { throw new Error(`API error: ${response.status}`); } - const contentType = response.headers.get('content-type') || ''; - if (!contentType.includes('application/json')) { - const text = await response.text(); - throw new Error(`API returned non-JSON response: ${text.slice(0, 80)}`); - } return response.json() as Promise; } +async function fetchJson(url: string): Promise { + const response = await fetch(url, { cache: 'no-store' }); + return handleResponse(response); +} + export async function fetchInventoryTree(): Promise { - const response = await fetch('http://127.0.0.1:8000/inventory/tree'); - const data = await handleResponse>(response); + const data = await fetchJson>('/inventory/tree'); return data.items; } export async function fetchNodeContext(id: string): Promise { - const response = await fetch(`http://127.0.0.1:8000/inventory/nodes/${id}/context`); - const data = await handleResponse>(response); + const data = await fetchJson>(`/inventory/nodes/${id}/context`); return data.item; }