diff --git a/src/app/layout.tsx b/src/app/layout.tsx index fc50c8b9..1f822b57 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -21,7 +21,7 @@ const ibmPlexMono = IBM_Plex_Mono({ export const metadata: Metadata = { title: SITE_TITLE, description: SITE_DESCRIPTION, - metadataBase: new URL(BASE_URL), + ...BASE_URL && { metadataBase: new URL(BASE_URL) }, openGraph: { title: SITE_TITLE, description: SITE_DESCRIPTION, diff --git a/src/site/config.ts b/src/site/config.ts index a3d0d4e3..4cfb07be 100644 --- a/src/site/config.ts +++ b/src/site/config.ts @@ -27,7 +27,7 @@ export const SITE_DESCRIPTION = SITE_DOMAIN; export const BASE_URL = process.env.NODE_ENV === 'production' - ? makeUrlAbsolute(SITE_DOMAIN).toLowerCase() + ? makeUrlAbsolute(SITE_DOMAIN)?.toLowerCase() : 'http://localhost:3000'; // STORAGE: VERCEL BLOB diff --git a/src/utility/url.ts b/src/utility/url.ts index 9272cd1a..71b2e887 100644 --- a/src/utility/url.ts +++ b/src/utility/url.ts @@ -6,7 +6,7 @@ export const shortenUrl = (url?: string) => url : undefined; // Add protocol to url and remove trailing slash -export const makeUrlAbsolute = (url = '') => - (!url.startsWith('http') - ? `https://${url}` - : url).replace(/\/$/, ''); +export const makeUrlAbsolute = (url?: string) => url !== undefined + ? (!url.startsWith('http') ? `https://${url}` : url) + .replace(/\/$/, '') + : undefined;