Skip to content

Scheduling infrastructure for absolutely everyone.

fix: routing form redirects to use app.cal.com instead of cal.com (#21924)

Anik Dhabal Babu3714d5faab91
diff --git a/packages/app-store/routing-forms/__tests__/getEventTypeRedirectUrl.test.ts b/packages/app-store/routing-forms/__tests__/getEventTypeRedirectUrl.test.ts
index 0e9e6f724b4..a24859d53ca 100644
--- a/packages/app-store/routing-forms/__tests__/getEventTypeRedirectUrl.test.ts
+++ b/packages/app-store/routing-forms/__tests__/getEventTypeRedirectUrl.test.ts
@@ -1,6 +1,6 @@
import { describe, it, expect } from "vitest";
-import { CAL_URL } from "@calcom/lib/constants";
+import { WEBAPP_URL } from "@calcom/lib/constants";
import { getAbsoluteEventTypeRedirectUrl } from "../getEventTypeRedirectUrl";
@@ -20,13 +20,13 @@ describe("getAbsoluteEventTypeRedirectUrl", () => {
isEmbed: false,
};
- it("should return CAL_URL for non-migrated user", () => {
+ it("should return WEBAPP_URL for non-migrated user", () => {
const result = getAbsoluteEventTypeRedirectUrl({
...defaultParams,
eventTypeRedirectUrl: "user/event",
form: { ...defaultForm, nonOrgUsername: "user" },
});
- expect(result).toBe(`${CAL_URL}/user/event?`);
+ expect(result).toBe(`${WEBAPP_URL}/user/event?`);
});
it("should return user origin for migrated user", () => {
@@ -34,13 +34,13 @@ describe("getAbsoluteEventTypeRedirectUrl", () => {
expect(result).toBe("https://user.cal.com/user/event?");
});
- it("should return CAL_URL for non-migrated team", () => {
+ it("should return WEBAPP_URL for non-migrated team", () => {
const result = getAbsoluteEventTypeRedirectUrl({
...defaultParams,
eventTypeRedirectUrl: "team/team1/event",
form: { ...defaultForm, nonOrgTeamslug: "team1" },
});
- expect(result).toBe(`${CAL_URL}/team/team1/event?`);
+ expect(result).toBe(`${WEBAPP_URL}/team/team1/event?`);
});
it("should return team origin for migrated team", () => {
diff --git a/packages/app-store/routing-forms/enrichFormWithMigrationData.ts b/packages/app-store/routing-forms/enrichFormWithMigrationData.ts
index f5deb5f8752..55863b273c0 100644
--- a/packages/app-store/routing-forms/enrichFormWithMigrationData.ts
+++ b/packages/app-store/routing-forms/enrichFormWithMigrationData.ts
@@ -1,5 +1,5 @@
import { getOrgFullOrigin } from "@calcom/features/ee/organizations/lib/orgDomains";
-import { CAL_URL } from "@calcom/lib/constants";
+import { WEBAPP_URL } from "@calcom/lib/constants";
import { teamMetadataSchema, userMetadata } from "@calcom/prisma/zod-utils";
export const enrichFormWithMigrationData = <
@@ -45,12 +45,12 @@ export const enrichFormWithMigrationData = <
? getOrgFullOrigin(formOwnerOrgSlug, {
protocol: true,
})
- : CAL_URL,
+ : WEBAPP_URL,
teamOrigin: form.team?.parent?.slug
? getOrgFullOrigin(form.team.parent.slug, {
protocol: true,
})
- : CAL_URL,
+ : WEBAPP_URL,
nonOrgUsername,
nonOrgTeamslug,
};
diff --git a/packages/features/embed/lib/EmbedTabs.tsx b/packages/features/embed/lib/EmbedTabs.tsx
index 183f5c55a0c..becc9762d27 100644
--- a/packages/features/embed/lib/EmbedTabs.tsx
+++ b/packages/features/embed/lib/EmbedTabs.tsx
@@ -3,7 +3,7 @@ import { forwardRef } from "react";
import type { BookerLayout } from "@calcom/features/bookings/Booker/types";
import { APP_NAME } from "@calcom/lib/constants";
-import { useBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
+import { useEmbedBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { TextArea } from "@calcom/ui/components/form";
@@ -188,7 +188,7 @@ ${getEmbedTypeSpecificString({
HTMLIFrameElement | HTMLTextAreaElement | null,
{ calLink: string; embedType: EmbedType; previewState: PreviewState; namespace: string }
>(function Preview({ calLink, embedType }, ref) {
- const bookerUrl = useBookerUrl();
+ const bookerUrl = useEmbedBookerUrl();
const iframeSrc = `${EMBED_PREVIEW_HTML_URL}?embedType=${embedType}&calLink=${calLink}&embedLibUrl=${embedLibUrl}&bookerUrl=${bookerUrl}`;
if (ref instanceof Function || !ref) {
return null;
@@ -329,7 +329,7 @@ const getInstructionString = ({
};
function useGetEmbedSnippetString(namespace: string | null) {
- const bookerUrl = useBookerUrl();
+ const bookerUrl = useEmbedBookerUrl();
// TODO: Import this string from @calcom/embed-snippet
// Right now the problem is that embed-snippet export is not minified and has comments which makes it unsuitable for giving it to users.
// If we can minify that during build time and then import the built code here, that could work
diff --git a/packages/features/embed/lib/hooks/index.tsx b/packages/features/embed/lib/hooks/index.tsx
index ea7f659bbec..1ac426ed72a 100644
--- a/packages/features/embed/lib/hooks/index.tsx
+++ b/packages/features/embed/lib/hooks/index.tsx
@@ -1,4 +1,4 @@
-import { useBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
+import { useEmbedBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
import { useLocale } from "@calcom/lib/hooks/useLocale";
export const useEmbedTypes = () => {
@@ -319,6 +319,6 @@ export const useEmbedTypes = () => {
};
export const useEmbedCalOrigin = () => {
- const bookerUrl = useBookerUrl();
+ const bookerUrl = useEmbedBookerUrl();
return bookerUrl;
};
diff --git a/packages/lib/hooks/useBookerUrl.ts b/packages/lib/hooks/useBookerUrl.ts
index 329afc73f41..d634c4b1d97 100644
--- a/packages/lib/hooks/useBookerUrl.ts
+++ b/packages/lib/hooks/useBookerUrl.ts
@@ -5,3 +5,8 @@ export const useBookerUrl = () => {
const orgBranding = useOrgBranding();
return orgBranding?.fullDomain ?? WEBSITE_URL ?? WEBAPP_URL;
};
+
+export const useEmbedBookerUrl = () => {
+ const orgBranding = useOrgBranding();
+ return orgBranding?.fullDomain ?? WEBAPP_URL;
+};