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