Make app more resilient to missing vercel project meta

This commit is contained in:
Sam Becker 2024-01-05 15:46:49 -06:00
parent c3fd40efa9
commit 7b6b819328
3 changed files with 6 additions and 6 deletions

View File

@ -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,

View File

@ -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

View File

@ -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;