Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update isCalcom for canonicals to handle https://cal.com #6802

Merged
merged 9 commits into from Jan 31, 2023
7 changes: 5 additions & 2 deletions packages/ui/components/head-seo/HeadSeo.tsx
Expand Up @@ -11,7 +11,6 @@ import {
} from "@calcom/lib/OgImages";
import { getBrowserInfo } from "@calcom/lib/browser/browser.utils";
import { APP_NAME } from "@calcom/lib/constants";
import isCalcom from "@calcom/lib/isCalcom";
import { seoConfig, getSeoImage } from "@calcom/lib/next-seo.config";
import { truncateOnWord } from "@calcom/lib/text";

Expand Down Expand Up @@ -76,8 +75,12 @@ const buildSeoMeta = (pageProps: {
export const HeadSeo = (props: HeadSeoProps): JSX.Element => {
// build the canonical url to ensure it's always cal.com (not app.cal.com)
const router = useRouter();
// compose the url with only the router's path (e.g. /apps/zapier) such that on app.cal.com the canonical is still cal.com
const calcomUrl = (`https://cal.com` + (router.asPath === "/" ? "" : router.asPath)).split("?")[0]; // cut off search params
const defaultUrl = isCalcom ? calcomUrl : getBrowserInfo()?.url;
const url = getBrowserInfo()?.url
// avoid setting cal.com canonicals on self-hosted apps. Note: isCalcom or IS_SELF_HOSTED from @calcom/lib do not handle https:cal.com
const isCalcom = new URL(url).hostname.endsWith("cal.com")
const defaultUrl = isCalcom ? calcomUrl : url;

const { title, description, siteName, canonical = defaultUrl, nextSeoProps = {}, app, meeting } = props;

Expand Down