Skip to content

Commit 26769cc

Browse files
CopilotoBusk
andcommitted
Make metadataBase dynamic for dev/preview environments
Use VERCEL_URL for preview deployments, localhost for development, and production URL as fallback. This allows OpenGraph images to work in all environments without hardcoding to production. Co-authored-by: oBusk <[email protected]>
1 parent 72aefb4 commit 26769cc

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
import "./.next/types/routes.d.ts";
3+
import "./.next/dev/types/routes.d.ts";
44

55
// NOTE: This file should not be edited
66
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

src/app/layout.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ import Header from "./_layout/Header";
88
import "./globals.css";
99

1010
export const metadata: Metadata = {
11-
metadataBase: new URL("https://npm-diff.app"),
11+
metadataBase: new URL(
12+
process.env.VERCEL_URL
13+
? `https://${process.env.VERCEL_URL}`
14+
: process.env.NODE_ENV === "development"
15+
? "http://localhost:3000"
16+
: "https://npm-diff.app",
17+
),
1218
applicationName: "npm-diff.app",
1319
title: {
1420
default: "npm-diff.app 📦🔃",

0 commit comments

Comments
 (0)