From ed6f9d825286a7e1a9d693ede281a605f4d19368 Mon Sep 17 00:00:00 2001 From: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Date: Mon, 18 Aug 2025 06:34:48 -0400 Subject: [PATCH] fix: Add cal.eu to `IS_CALCOM` (#23111) * Add cal.eu to `IS_CALCOM` * Create `getCalcomUrl` function * Use `getCalcomURl` in generate metadata * Use `getCalcomURl` in `buildCanonical` * Linting fix --- apps/web/app/_utils.tsx | 3 ++- apps/web/components/PageWrapper.tsx | 3 ++- packages/lib/constants.ts | 3 ++- packages/lib/getCalcomUrl.ts | 8 ++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 packages/lib/getCalcomUrl.ts diff --git a/apps/web/app/_utils.tsx b/apps/web/app/_utils.tsx index 49cbee6463..f9d6c3705b 100644 --- a/apps/web/app/_utils.tsx +++ b/apps/web/app/_utils.tsx @@ -5,6 +5,7 @@ import { getLocale } from "@calcom/features/auth/lib/getLocale"; import type { AppImageProps, MeetingImageProps } from "@calcom/lib/OgImages"; import { constructAppImage, constructGenericImage, constructMeetingImage } from "@calcom/lib/OgImages"; import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG, CAL_URL } from "@calcom/lib/constants"; +import { getCalcomUrl } from "@calcom/lib/getCalcomUrl"; import { buildCanonical } from "@calcom/lib/next-seo.config"; import { getTranslation } from "@calcom/lib/server/i18n"; import { truncateOnWord } from "@calcom/lib/text"; @@ -32,7 +33,7 @@ const _generateMetadataWithoutImage = async ( const description = getDescription(t); const titleSuffix = `| ${APP_NAME}`; const displayedTitle = title.includes(titleSuffix) || hideBranding ? title : `${title} ${titleSuffix}`; - const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL); + const metadataBase = new URL(IS_CALCOM ? getCalcomUrl() : WEBAPP_URL); return { title: title.length === 0 ? APP_NAME : displayedTitle, diff --git a/apps/web/components/PageWrapper.tsx b/apps/web/components/PageWrapper.tsx index 957b388152..238d2f982f 100644 --- a/apps/web/components/PageWrapper.tsx +++ b/apps/web/components/PageWrapper.tsx @@ -9,6 +9,7 @@ import Script from "next/script"; import "@calcom/embed-core/src/embed-iframe"; import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired"; import { IS_CALCOM, WEBAPP_URL } from "@calcom/lib/constants"; +import { getCalcomUrl } from "@calcom/lib/getCalcomUrl"; import { buildCanonical } from "@calcom/lib/next-seo.config"; import { IconSprites } from "@calcom/ui/components/icon"; @@ -64,7 +65,7 @@ function PageWrapper(props: AppProps) { // Set canonical to https://cal.com or self-hosted URL canonical={ IS_CALCOM - ? buildCanonical({ path, origin: "https://cal.com" }) // cal.com & .dev + ? buildCanonical({ path, origin: getCalcomUrl() }) // cal.com & .dev : buildCanonical({ path, origin: WEBAPP_URL }) // self-hosted } {...seoConfig.defaultNextSeo} diff --git a/packages/lib/constants.ts b/packages/lib/constants.ts index ce54e31f3e..3bac575a0c 100644 --- a/packages/lib/constants.ts +++ b/packages/lib/constants.ts @@ -45,7 +45,8 @@ export const IS_CALCOM = (new URL(WEBAPP_URL).hostname.endsWith("cal.com") || new URL(WEBAPP_URL).hostname.endsWith("cal.dev") || new URL(WEBAPP_URL).hostname.endsWith("cal.qa") || - new URL(WEBAPP_URL).hostname.endsWith("cal-staging.com")); + new URL(WEBAPP_URL).hostname.endsWith("cal-staging.com") || + new URL(WEBAPP_URL).hostname.endsWith("cal.eu")); export const CONSOLE_URL = new URL(WEBAPP_URL).hostname.endsWith(".cal.dev") || diff --git a/packages/lib/getCalcomUrl.ts b/packages/lib/getCalcomUrl.ts new file mode 100644 index 0000000000..1e45137a1c --- /dev/null +++ b/packages/lib/getCalcomUrl.ts @@ -0,0 +1,8 @@ +import { WEBAPP_URL, IS_CALCOM } from "./constants"; + +export const getCalcomUrl = () => { + if (IS_CALCOM) { + return new URL(WEBAPP_URL).hostname.endsWith("cal.eu") ? "https://cal.eu" : "https://cal.com"; + } + return WEBAPP_URL; +};