mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 16:05:23 +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',
|
||||
headers: {
|
||||
'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();
|
||||
} catch (error) {
|
||||
console.error('Error fetching history from Supabase:', error);
|
||||
return [];
|
||||
} catch (error: any) {
|
||||
console.error('Error fetching history:', error);
|
||||
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