Enforce no-cache for API calls

Ensure all API requests include no-cache headers to avoid cached CORS issues. Added Cache-Control, Pragma headers and set fetch to no-store, so requests are not cached.

X-Lovable-Edit-ID: edt-17929842-67a4-4e77-8ea7-1e46d2ee30fc
This commit is contained in:
gpt-engineer-app[bot]
2026-01-12 01:24:59 +00:00
+3
View File
@@ -113,6 +113,8 @@ async function request<T>(
): Promise<T> { ): Promise<T> {
const headers: Record<string, string> = { const headers: Record<string, string> = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Cache-Control': 'no-cache, no-store, must-revalidate',
'Pragma': 'no-cache',
...(options.headers as Record<string, string>), ...(options.headers as Record<string, string>),
}; };
@@ -127,6 +129,7 @@ async function request<T>(
const response = await fetch(`${config.api.baseUrl}${endpoint}`, { const response = await fetch(`${config.api.baseUrl}${endpoint}`, {
...options, ...options,
headers, headers,
cache: 'no-store',
}); });
const json: ApiResponse<T> = await response.json(); const json: ApiResponse<T> = await response.json();