From 7f5496704a9b1515709bf621a94db662b193e630 Mon Sep 17 00:00:00 2001 From: visrut Date: Tue, 24 Oct 2023 19:26:55 +0530 Subject: [PATCH] fix: remove hardcoded URL from SEO --- app/config.ts | 2 ++ app/survey/[id]/layout.tsx | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 app/config.ts diff --git a/app/config.ts b/app/config.ts new file mode 100644 index 0000000..b4ebc0f --- /dev/null +++ b/app/config.ts @@ -0,0 +1,2 @@ +const dev = process.env.NODE_ENV !== 'production' +export const server = dev ? 'http://localhost:3000' : 'https://wizardsurvey.fun' diff --git a/app/survey/[id]/layout.tsx b/app/survey/[id]/layout.tsx index 9d18bda..76c7e6c 100644 --- a/app/survey/[id]/layout.tsx +++ b/app/survey/[id]/layout.tsx @@ -1,3 +1,4 @@ +import { server } from '@/app/config' import { AppProvider } from '@/app/context/AppContext' import { Metadata, ResolvingMetadata } from 'next' @@ -7,7 +8,7 @@ export async function generateMetadata( ): Promise { const id = params.id - const survey = await fetch(`http://localhost:3000/survey/${id}/api`).then((res) => res.json()) + const survey = await fetch(`${server}/survey/${id}/api`).then((res) => res.json()) const previousImages = (await parent).openGraph?.images || []