fix: Add cache-busting to API fetch calls

Prevents browser from caching API responses when changing date ranges,
which caused stat cards to show stale data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
DJP 2026-03-19 14:07:03 -04:00
parent 3d3c8a1a54
commit 31a70bbef2

View file

@ -37,7 +37,8 @@ const BASE_PATH = window.location.pathname.replace(/\/$/, '');
async function fetchAPI(endpoint) {
const sep = endpoint.includes('?') ? '&' : '?';
const res = await fetch(`${BASE_PATH}/api/${endpoint}${sep}${queryParams()}`, { headers: apiHeaders() });
const url = `${BASE_PATH}/api/${endpoint}${sep}${queryParams()}&_t=${Date.now()}`;
const res = await fetch(url, { headers: apiHeaders(), cache: 'no-store' });
if (!res.ok) throw new Error(`API error: ${res.status}`);
return res.json();
}