Просмотр исходного кода

fix: Use dedicated share-image endpoint for private bucket images

Simplify SharedImagePage to use /api/share-image/{code} endpoint which
handles authentication bypass and serves images from private buckets.
Fszontagh 3 дней назад
Родитель
Сommit
031683cce3
1 измененных файлов с 3 добавлено и 13 удалено
  1. 3 13
      src/pages/SharedImagePage.tsx

+ 3 - 13
src/pages/SharedImagePage.tsx

@@ -47,19 +47,9 @@ export default function SharedImagePage() {
           return;
         }
 
-        // Fetch the share link data to get the image_short_code using SDK
-        const linkDataRes = await client
-          .from<{ image_short_code: string }>('share_links')
-          .select('image_short_code')
-          .eq('link_code', shareId)
-          .limit(1)
-          .get();
-
-        if (!linkDataRes.error && linkDataRes.data && linkDataRes.data.length > 0) {
-          const imageShortCode = linkDataRes.data[0].image_short_code;
-          // Use direct storage path with short code
-          setImageUrl(`/i/${imageShortCode}`);
-        }
+        // Use the dedicated share-image endpoint which handles auth and serves the image
+        // This endpoint validates the share link and serves images from private buckets
+        setImageUrl(`/api/share-image/${shareId}`);
 
         // Increment view count using SDK (fire and forget)
         incrementViewCount(client, shareId).catch(console.warn);