Skip to content

Commit ed6f9d8

Browse files
authored
fix: Add cal.eu to IS_CALCOM (calcom#23111)
* Add cal.eu to `IS_CALCOM` * Create `getCalcomUrl` function * Use `getCalcomURl` in generate metadata * Use `getCalcomURl` in `buildCanonical` * Linting fix
1 parent a19ccab commit ed6f9d8

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

apps/web/app/_utils.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getLocale } from "@calcom/features/auth/lib/getLocale";
55
import type { AppImageProps, MeetingImageProps } from "@calcom/lib/OgImages";
66
import { constructAppImage, constructGenericImage, constructMeetingImage } from "@calcom/lib/OgImages";
77
import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG, CAL_URL } from "@calcom/lib/constants";
8+
import { getCalcomUrl } from "@calcom/lib/getCalcomUrl";
89
import { buildCanonical } from "@calcom/lib/next-seo.config";
910
import { getTranslation } from "@calcom/lib/server/i18n";
1011
import { truncateOnWord } from "@calcom/lib/text";
@@ -32,7 +33,7 @@ const _generateMetadataWithoutImage = async (
3233
const description = getDescription(t);
3334
const titleSuffix = `| ${APP_NAME}`;
3435
const displayedTitle = title.includes(titleSuffix) || hideBranding ? title : `${title} ${titleSuffix}`;
35-
const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL);
36+
const metadataBase = new URL(IS_CALCOM ? getCalcomUrl() : WEBAPP_URL);
3637

3738
return {
3839
title: title.length === 0 ? APP_NAME : displayedTitle,

apps/web/components/PageWrapper.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Script from "next/script";
99
import "@calcom/embed-core/src/embed-iframe";
1010
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
1111
import { IS_CALCOM, WEBAPP_URL } from "@calcom/lib/constants";
12+
import { getCalcomUrl } from "@calcom/lib/getCalcomUrl";
1213
import { buildCanonical } from "@calcom/lib/next-seo.config";
1314
import { IconSprites } from "@calcom/ui/components/icon";
1415

@@ -64,7 +65,7 @@ function PageWrapper(props: AppProps) {
6465
// Set canonical to https://cal.com or self-hosted URL
6566
canonical={
6667
IS_CALCOM
67-
? buildCanonical({ path, origin: "https://cal.com" }) // cal.com & .dev
68+
? buildCanonical({ path, origin: getCalcomUrl() }) // cal.com & .dev
6869
: buildCanonical({ path, origin: WEBAPP_URL }) // self-hosted
6970
}
7071
{...seoConfig.defaultNextSeo}

packages/lib/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export const IS_CALCOM =
4545
(new URL(WEBAPP_URL).hostname.endsWith("cal.com") ||
4646
new URL(WEBAPP_URL).hostname.endsWith("cal.dev") ||
4747
new URL(WEBAPP_URL).hostname.endsWith("cal.qa") ||
48-
new URL(WEBAPP_URL).hostname.endsWith("cal-staging.com"));
48+
new URL(WEBAPP_URL).hostname.endsWith("cal-staging.com") ||
49+
new URL(WEBAPP_URL).hostname.endsWith("cal.eu"));
4950

5051
export const CONSOLE_URL =
5152
new URL(WEBAPP_URL).hostname.endsWith(".cal.dev") ||

packages/lib/getCalcomUrl.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { WEBAPP_URL, IS_CALCOM } from "./constants";
2+
3+
export const getCalcomUrl = () => {
4+
if (IS_CALCOM) {
5+
return new URL(WEBAPP_URL).hostname.endsWith("cal.eu") ? "https://cal.eu" : "https://cal.com";
6+
}
7+
return WEBAPP_URL;
8+
};

0 commit comments

Comments
 (0)