From dcbf6f82d8503cbccd1208fdf92b4ee7fd4a6bc3 Mon Sep 17 00:00:00 2001 From: BennyKok Date: Sun, 17 Dec 2023 21:40:54 +0800 Subject: [PATCH] fix: url display in code block --- web/src/components/DeploymentDisplay.tsx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/web/src/components/DeploymentDisplay.tsx b/web/src/components/DeploymentDisplay.tsx index b7936a1..e42664e 100644 --- a/web/src/components/DeploymentDisplay.tsx +++ b/web/src/components/DeploymentDisplay.tsx @@ -11,6 +11,7 @@ import { TableCell, TableRow } from "@/components/ui/table"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { getRelativeTime } from "@/lib/getRelativeTime"; import type { findAllDeployments } from "@/server/findAllRuns"; +import { headers } from 'next/headers'; const curlTemplate = ` curl --request POST \ @@ -57,6 +58,11 @@ export function DeploymentDisplay({ }: { deployment: Awaited>[0]; }) { + const headersList = headers(); + const host = headersList.get('host') || ""; + const protocol = headersList.get("x-forwarded-proto") || ""; + const domain = `${protocol}://${host}`; + return ( @@ -87,21 +93,21 @@ export function DeploymentDisplay({ Trigger the workflow - + Check the status of the run, and retrieve the outputs @@ -112,12 +118,13 @@ export function DeploymentDisplay({ function formatCode( codeTemplate: string, - deployment: Awaited>[0] + deployment: Awaited>[0], + domain: string ) { return codeTemplate .replace( "", - `${process.env.VERCEL_URL ?? "http://localhost:3000"}/api/run` + `${domain ?? "http://localhost:3000"}/api/run` ) .replace("", deployment.id); }