Skip to content

Commit 3714d5f

Browse files
fix: routing form redirects to use app.cal.com instead of cal.com (calcom#21924)
* fix: routing form redirects to use app.cal.com instead of cal.com * Update packages/lib/hooks/useBookerUrl.ts Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> * update --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
1 parent 12cb949 commit 3714d5f

5 files changed

Lines changed: 18 additions & 13 deletions

File tree

packages/app-store/routing-forms/__tests__/getEventTypeRedirectUrl.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, it, expect } from "vitest";
22

3-
import { CAL_URL } from "@calcom/lib/constants";
3+
import { WEBAPP_URL } from "@calcom/lib/constants";
44

55
import { getAbsoluteEventTypeRedirectUrl } from "../getEventTypeRedirectUrl";
66

@@ -20,27 +20,27 @@ describe("getAbsoluteEventTypeRedirectUrl", () => {
2020
isEmbed: false,
2121
};
2222

23-
it("should return CAL_URL for non-migrated user", () => {
23+
it("should return WEBAPP_URL for non-migrated user", () => {
2424
const result = getAbsoluteEventTypeRedirectUrl({
2525
...defaultParams,
2626
eventTypeRedirectUrl: "user/event",
2727
form: { ...defaultForm, nonOrgUsername: "user" },
2828
});
29-
expect(result).toBe(`${CAL_URL}/user/event?`);
29+
expect(result).toBe(`${WEBAPP_URL}/user/event?`);
3030
});
3131

3232
it("should return user origin for migrated user", () => {
3333
const result = getAbsoluteEventTypeRedirectUrl(defaultParams);
3434
expect(result).toBe("https://user.cal.com/user/event?");
3535
});
3636

37-
it("should return CAL_URL for non-migrated team", () => {
37+
it("should return WEBAPP_URL for non-migrated team", () => {
3838
const result = getAbsoluteEventTypeRedirectUrl({
3939
...defaultParams,
4040
eventTypeRedirectUrl: "team/team1/event",
4141
form: { ...defaultForm, nonOrgTeamslug: "team1" },
4242
});
43-
expect(result).toBe(`${CAL_URL}/team/team1/event?`);
43+
expect(result).toBe(`${WEBAPP_URL}/team/team1/event?`);
4444
});
4545

4646
it("should return team origin for migrated team", () => {

packages/app-store/routing-forms/enrichFormWithMigrationData.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getOrgFullOrigin } from "@calcom/features/ee/organizations/lib/orgDomains";
2-
import { CAL_URL } from "@calcom/lib/constants";
2+
import { WEBAPP_URL } from "@calcom/lib/constants";
33
import { teamMetadataSchema, userMetadata } from "@calcom/prisma/zod-utils";
44

55
export const enrichFormWithMigrationData = <
@@ -45,12 +45,12 @@ export const enrichFormWithMigrationData = <
4545
? getOrgFullOrigin(formOwnerOrgSlug, {
4646
protocol: true,
4747
})
48-
: CAL_URL,
48+
: WEBAPP_URL,
4949
teamOrigin: form.team?.parent?.slug
5050
? getOrgFullOrigin(form.team.parent.slug, {
5151
protocol: true,
5252
})
53-
: CAL_URL,
53+
: WEBAPP_URL,
5454
nonOrgUsername,
5555
nonOrgTeamslug,
5656
};

packages/features/embed/lib/EmbedTabs.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { forwardRef } from "react";
33

44
import type { BookerLayout } from "@calcom/features/bookings/Booker/types";
55
import { APP_NAME } from "@calcom/lib/constants";
6-
import { useBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
6+
import { useEmbedBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
77
import { useLocale } from "@calcom/lib/hooks/useLocale";
88
import { TextArea } from "@calcom/ui/components/form";
99

@@ -188,7 +188,7 @@ ${getEmbedTypeSpecificString({
188188
HTMLIFrameElement | HTMLTextAreaElement | null,
189189
{ calLink: string; embedType: EmbedType; previewState: PreviewState; namespace: string }
190190
>(function Preview({ calLink, embedType }, ref) {
191-
const bookerUrl = useBookerUrl();
191+
const bookerUrl = useEmbedBookerUrl();
192192
const iframeSrc = `${EMBED_PREVIEW_HTML_URL}?embedType=${embedType}&calLink=${calLink}&embedLibUrl=${embedLibUrl}&bookerUrl=${bookerUrl}`;
193193
if (ref instanceof Function || !ref) {
194194
return null;
@@ -329,7 +329,7 @@ const getInstructionString = ({
329329
};
330330

331331
function useGetEmbedSnippetString(namespace: string | null) {
332-
const bookerUrl = useBookerUrl();
332+
const bookerUrl = useEmbedBookerUrl();
333333
// TODO: Import this string from @calcom/embed-snippet
334334
// Right now the problem is that embed-snippet export is not minified and has comments which makes it unsuitable for giving it to users.
335335
// If we can minify that during build time and then import the built code here, that could work

packages/features/embed/lib/hooks/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
1+
import { useEmbedBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
22
import { useLocale } from "@calcom/lib/hooks/useLocale";
33

44
export const useEmbedTypes = () => {
@@ -319,6 +319,6 @@ export const useEmbedTypes = () => {
319319
};
320320

321321
export const useEmbedCalOrigin = () => {
322-
const bookerUrl = useBookerUrl();
322+
const bookerUrl = useEmbedBookerUrl();
323323
return bookerUrl;
324324
};

packages/lib/hooks/useBookerUrl.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ export const useBookerUrl = () => {
55
const orgBranding = useOrgBranding();
66
return orgBranding?.fullDomain ?? WEBSITE_URL ?? WEBAPP_URL;
77
};
8+
9+
export const useEmbedBookerUrl = () => {
10+
const orgBranding = useOrgBranding();
11+
return orgBranding?.fullDomain ?? WEBAPP_URL;
12+
};

0 commit comments

Comments
 (0)