mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-30 16:14:13 +00:00
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
This commit is contained in:
@@ -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: {
|
||||
|
||||
@@ -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}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user