From 2139f1ac6c1d85d123ef3f67d8040baa7ba45316 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Mar 2026 15:44:56 +0000 Subject: [PATCH] Use siteConfig instead of NEXT_PUBLIC_APP_URL for root layout metadata The metadata in the root layout referenced process.env.NEXT_PUBLIC_APP_URL with non-null assertions, but this env var is not guaranteed to be set (only .env.example exists). This caused `new URL(undefined)` to throw during SSR, resulting in a blank page on /create (and all other routes). Replace all NEXT_PUBLIC_APP_URL references in metadata with siteConfig.url and siteConfig.ogImage, which are already defined and used elsewhere in the same metadata block. https://claude.ai/code/session_01Ez3f6QxR3MxNq6YfAeqrcH --- apps/v4/app/layout.tsx | 10 ++++------ apps/v4/lib/utils.ts | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/v4/app/layout.tsx b/apps/v4/app/layout.tsx index 73914d26a1..538b59c13a 100644 --- a/apps/v4/app/layout.tsx +++ b/apps/v4/app/layout.tsx @@ -20,9 +20,7 @@ export const metadata: Metadata = { default: siteConfig.name, template: `%s - ${siteConfig.name}`, }, - metadataBase: new URL( - process.env.NEXT_PUBLIC_APP_URL ?? "http://localhost:4000" - ), + metadataBase: new URL(siteConfig.url), description: siteConfig.description, keywords: ["Next.js", "React", "Tailwind CSS", "Components", "shadcn"], authors: [ @@ -35,13 +33,13 @@ export const metadata: Metadata = { openGraph: { type: "website", locale: "en_US", - url: process.env.NEXT_PUBLIC_APP_URL!, + url: siteConfig.url, title: siteConfig.name, description: siteConfig.description, siteName: siteConfig.name, images: [ { - url: `${process.env.NEXT_PUBLIC_APP_URL}/opengraph-image.png`, + url: siteConfig.ogImage, width: 1200, height: 630, alt: siteConfig.name, @@ -52,7 +50,7 @@ export const metadata: Metadata = { card: "summary_large_image", title: siteConfig.name, description: siteConfig.description, - images: [`${process.env.NEXT_PUBLIC_APP_URL}/opengraph-image.png`], + images: [siteConfig.ogImage], creator: "@shadcn", }, icons: { diff --git a/apps/v4/lib/utils.ts b/apps/v4/lib/utils.ts index 57f38170f0..8b4c50fc38 100644 --- a/apps/v4/lib/utils.ts +++ b/apps/v4/lib/utils.ts @@ -6,5 +6,5 @@ export function cn(...inputs: ClassValue[]) { } export function absoluteUrl(path: string) { - return `${process.env.NEXT_PUBLIC_APP_URL ?? "http://localhost:4000"}${path}` + return `${process.env.NEXT_PUBLIC_APP_URL}${path}` }