diff --git a/web/.env.example b/web/.env.example index a356370..ded4e58 100644 --- a/web/.env.example +++ b/web/.env.example @@ -10,6 +10,8 @@ SPACES_REGION="nyc3" SPACES_BUCKET="comfyui-deploy" SPACES_KEY="xyz" SPACES_SECRET="aaa" +SPACES_CDN_DONT_INCLUDE_BUCKET="false" +SPACES_CDN_FORCE_PATH_STYLE="true" JWT_SECRET="openssl rand -hex 32" PLAUSIBLE_DOMAIN= \ No newline at end of file diff --git a/web/src/components/DownloadButton.tsx b/web/src/components/DownloadButton.tsx new file mode 100644 index 0000000..e6c3e13 --- /dev/null +++ b/web/src/components/DownloadButton.tsx @@ -0,0 +1,27 @@ +"use client"; + +import { Button } from "@/components/ui/button"; +import { Download } from "lucide-react"; + +export function DownloadButton(props: { href: string; filename: string }) { + return ( + + ); +} diff --git a/web/src/components/OutputRender.tsx b/web/src/components/OutputRender.tsx index f84bdc5..2977d8f 100644 --- a/web/src/components/OutputRender.tsx +++ b/web/src/components/OutputRender.tsx @@ -1,40 +1,22 @@ -"use client"; - -import { Button } from "@/components/ui/button"; +import { DownloadButton } from "./DownloadButton"; import { getFileDownloadUrl } from "@/server/getFileDownloadUrl"; -import { Download } from "lucide-react"; -export function OutputRender(props: { run_id: string; filename: string }) { +export async function OutputRender(props: { + run_id: string; + filename: string; +}) { if (props.filename.endsWith(".png")) { - return ( - {props.filename} + const url = await getFileDownloadUrl( + `outputs/runs/${props.run_id}/${props.filename}` ); - } else { - return ( - + return {props.filename}; + } else { + const url = await getFileDownloadUrl( + `outputs/runs/${props.run_id}/${props.filename}` ); + console.log(url); + + return ; } } diff --git a/web/src/server/replaceCDNUrl.ts b/web/src/server/replaceCDNUrl.ts index d719b71..f186752 100644 --- a/web/src/server/replaceCDNUrl.ts +++ b/web/src/server/replaceCDNUrl.ts @@ -7,9 +7,10 @@ export function replaceCDNUrl(url: string) { ); // When using digital ocean, we need to use the bucket name in the URL } else if (process.env.SPACES_CDN_FORCE_PATH_STYLE === "false") { + const cdnUrl = new URL(process.env.SPACES_ENDPOINT_CDN!); url = url.replace( `${process.env.SPACES_ENDPOINT}/${process.env.SPACES_BUCKET}`, - `${process.env.SPACES_BUCKET}.${process.env.SPACES_ENDPOINT_CDN}}` + `${cdnUrl.protocol}//${process.env.SPACES_BUCKET}.${cdnUrl.host}` ); } else { url = url.replace(