mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 15:11:12 -05:00
Fix image deletion authentication
This commit is contained in:
@@ -489,23 +489,17 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
||||
try {
|
||||
console.log('Attempting to delete image from Cloudflare:', imageId);
|
||||
|
||||
// Direct fetch call to the edge function with proper DELETE method
|
||||
const response = await fetch('https://ydvtmnrszybqnbcqbdcy.supabase.co/functions/v1/upload-image', {
|
||||
// Use Supabase SDK - automatically includes session token
|
||||
const { data, error } = await supabase.functions.invoke('upload-image', {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InlkdnRtbnJzenlicW5iY3FiZGN5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTgzMjYzNTYsImV4cCI6MjA3MzkwMjM1Nn0.DM3oyapd_omP5ZzIlrT0H9qBsiQBxBRgw2tYuqgXKX4`
|
||||
},
|
||||
body: JSON.stringify({ imageId })
|
||||
body: { imageId }
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.text();
|
||||
throw new Error(`HTTP ${response.status}: ${errorData}`);
|
||||
if (error) {
|
||||
throw new Error(`Failed to delete image: ${error.message}`);
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
console.log('Successfully deleted image:', imageId, result);
|
||||
console.log('Successfully deleted image:', imageId, data);
|
||||
|
||||
} catch (deleteError) {
|
||||
console.error(`Failed to delete photo ${imageId} from Cloudflare:`, deleteError);
|
||||
|
||||
Reference in New Issue
Block a user