mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 17:25:24 +02:00
Force anon key on getHistory and expose errors visually
This commit is contained in:
+25
-5
@@ -133,16 +133,36 @@ export async function getHistory(token?: string): Promise<HistoryEntry[]> {
|
|||||||
cache: 'no-store',
|
cache: 'no-store',
|
||||||
headers: {
|
headers: {
|
||||||
'apikey': SUPABASE_KEY,
|
'apikey': SUPABASE_KEY,
|
||||||
'Authorization': `Bearer ${token || SUPABASE_KEY}`
|
// Try using only the ANON key just in case RLS or token expiry is failing silently
|
||||||
|
'Authorization': `Bearer ${SUPABASE_KEY}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!response.ok) return [];
|
if (!response.ok) {
|
||||||
|
const err = await response.text();
|
||||||
|
return [{
|
||||||
|
id: 'error-' + Date.now(),
|
||||||
|
product_id: 'ERROR',
|
||||||
|
article_name: `Failed: ${response.status} ${err}`,
|
||||||
|
old_data: [],
|
||||||
|
new_data: [],
|
||||||
|
changed_at: new Date().toISOString(),
|
||||||
|
changed_by: 'system'
|
||||||
|
}];
|
||||||
|
}
|
||||||
return await response.json();
|
return await response.json();
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
console.error('Error fetching history from Supabase:', error);
|
console.error('Error fetching history:', error);
|
||||||
return [];
|
return [{
|
||||||
|
id: 'error-' + Date.now(),
|
||||||
|
product_id: 'EXCEPTION',
|
||||||
|
article_name: `Message: ${error.message}`,
|
||||||
|
old_data: [],
|
||||||
|
new_data: [],
|
||||||
|
changed_at: new Date().toISOString(),
|
||||||
|
changed_by: 'system'
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user