From a29f191d03cada7467b4657f5ab694505f7b2fd5 Mon Sep 17 00:00:00 2001 From: xavidop Date: Wed, 23 Jul 2025 19:03:30 +0200 Subject: [PATCH] fix: shareutils --- src/utils/shareUtils.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/utils/shareUtils.ts b/src/utils/shareUtils.ts index 187e823..96d5eda 100644 --- a/src/utils/shareUtils.ts +++ b/src/utils/shareUtils.ts @@ -209,8 +209,18 @@ export const nativeShare = async ({ cardName, cardImageUrl }: ShareOptions) => { // If we have an image and the browser supports file sharing if (cardImageUrl && navigator.canShare) { try { - // Convert data URL or Firebase Storage URL to blob - const response = await fetch(cardImageUrl); + let fetchUrl = cardImageUrl; + + // If it's a Firebase Storage URL (not a data URL), use the download route + if (cardImageUrl.startsWith('http') && + (cardImageUrl.includes('firebasestorage.googleapis.com') || + cardImageUrl.includes('localhost:9199') || + cardImageUrl.includes('127.0.0.1:9199'))) { + fetchUrl = `/api/download?url=${encodeURIComponent(cardImageUrl)}`; + } + + // Convert data URL or use download route to get blob + const response = await fetch(fetchUrl); const blob = await response.blob(); const file = new File([blob], `${cardName}-card.png`, { type: 'image/png' });