From 67c576fc66d248a1821a108214cd4f8f3bf31e73 Mon Sep 17 00:00:00 2001 From: Aamir Azad Date: Thu, 11 Jul 2024 10:22:11 -0400 Subject: [PATCH] Download button doesn't work cause of cors --- src/components/audio-preview.tsx | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/components/audio-preview.tsx b/src/components/audio-preview.tsx index 6cb11cb..a5f93db 100644 --- a/src/components/audio-preview.tsx +++ b/src/components/audio-preview.tsx @@ -66,21 +66,18 @@ async function fetchWhishperRecording(searchId: string, whishperURL: string) { } async function downloadWhishperRecording(url: string, name: string) { - const [recordingUrl, setRecordingUrl] = useState(""); const response = await fetch(url); if (response.ok) { const blob = await response.blob(); - setRecordingUrl(URL.createObjectURL(blob)); + const recordingUrl = URL.createObjectURL(blob); + const link = document.createElement("a"); + link.download = name; + link.href = recordingUrl; + link.click(); } else { console.error("Failed to download"); return null; } - const link = document.createElement("a"); - link.download = name; - - link.href = recordingUrl; - - link.click(); } type AudioInfoProps = { @@ -197,7 +194,16 @@ function AudioInfo({ id }: AudioInfoProps) { > Download - +