Replace WEB_URL with DEPLOYED_WEB_URL for dynamic environment support in Open Graph utilities and SEO components.

This commit is contained in:
MartinBraquet
2026-04-09 20:50:15 +02:00
parent b65dae9ff7
commit 288573a36f
2 changed files with 12 additions and 11 deletions

View File

@@ -1,9 +1,9 @@
import {WEB_URL} from 'common/envs/constants'
import {DEPLOYED_WEB_URL} from 'common/envs/constants'
// opengraph functions that run in static props or client-side, but not in the edge (in image creation)
export function buildOgUrl<P extends Record<string, string>>(props: P, endpoint: string) {
const generateUrlParams = (params: P) => new URLSearchParams(params).toString()
return `${WEB_URL}/api/og/${endpoint}?` + generateUrlParams(props)
return `${DEPLOYED_WEB_URL}/api/og/${endpoint}?` + generateUrlParams(props)
}

View File

@@ -1,4 +1,4 @@
import {endTitle} from 'common/envs/constants'
import {DEPLOYED_WEB_URL, endTitle} from 'common/envs/constants'
import {removeUndefinedProps} from 'common/util/object'
import {buildOgUrl} from 'common/util/og'
import Head from 'next/head'
@@ -15,20 +15,21 @@ export function SEO<P extends Record<string, string | undefined>>(props: {
const imageUrl =
image ?? (ogProps && buildOgUrl(removeUndefinedProps(ogProps.props) as any, ogProps.endpoint))
const absUrl = 'https://compassmeet.com' + url
const absUrl = DEPLOYED_WEB_URL + url
return (
<Head>
<title>{`${title} | ${endTitle}`}</title>
<meta property="og:title" name="twitter:title" content={title} key="title" />
{/*OG tags (WhatsApp, Facebook, etc.)*/}
<meta property="og:title" content={title} key="title" />
<meta property="og:description" content={description} key="description3" />
{/*Twitter/X tags — separate!*/}
<meta name="twitter:title" content={title} key="title" />
<meta name="twitter:description" content={description} key="description2" />
<meta name="description" content={description} key="description1" />
<meta
property="og:description"
name="twitter:description"
content={description}
key="description2"
/>
{url && <link rel="canonical" href={absUrl} />}