diff --git a/apps/web/pages/event-types/index.tsx b/apps/web/pages/event-types/index.tsx
index 72e5e2c53e..34a4898954 100644
--- a/apps/web/pages/event-types/index.tsx
+++ b/apps/web/pages/event-types/index.tsx
@@ -16,6 +16,7 @@ import { TeamsFilter } from "@calcom/features/filters/components/TeamsFilter";
import { getTeamsFiltersFromQuery } from "@calcom/features/filters/lib/getTeamsFiltersFromQuery";
import Shell from "@calcom/features/shell/Shell";
import { APP_NAME, CAL_URL, WEBAPP_URL } from "@calcom/lib/constants";
+import { useBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import useMediaQuery from "@calcom/lib/hooks/useMediaQuery";
import { useTypedQuery } from "@calcom/lib/hooks/useTypedQuery";
@@ -710,7 +711,7 @@ const EventTypeListHeading = ({
showToast(error.message, "error");
},
});
-
+ const bookerUrl = useBookerUrl();
return (
- {orgBranding
- ? `${orgBranding.fullDomain.replace("https://", "").replace("http://", "")}${profile.slug}`
- : `${CAL_URL?.replace("https://", "").replace("http://", "")}/${profile.slug}`}
+ {`${bookerUrl.replace("https://", "").replace("http://", "")}/${profile.slug}`}
)}
diff --git a/packages/app-store/routing-forms/pages/router/[...appPages].tsx b/packages/app-store/routing-forms/pages/router/[...appPages].tsx
index 6d5e2c9dcb..bde18dd502 100644
--- a/packages/app-store/routing-forms/pages/router/[...appPages].tsx
+++ b/packages/app-store/routing-forms/pages/router/[...appPages].tsx
@@ -1,6 +1,7 @@
import Head from "next/head";
import z from "zod";
+import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
import type { AppGetServerSidePropsContext, AppPrisma } from "@calcom/types/AppGetServerSideProps";
import type { inferSSRProps } from "@calcom/types/inferSSRProps";
@@ -47,11 +48,21 @@ export const getServerSideProps = async function getServerSideProps(
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { form: formId, slug: _slug, pages: _pages, ...fieldsResponses } = queryParsed.data;
- const form = await prisma.app_RoutingForms_Form.findUnique({
+ const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(context.req.headers.host ?? "");
+
+ const form = await prisma.app_RoutingForms_Form.findFirst({
where: {
id: formId,
+ user: {
+ organization: isValidOrgDomain
+ ? {
+ slug: currentOrgDomain,
+ }
+ : null,
+ },
},
});
+
if (!form) {
return {
notFound: true,
diff --git a/packages/app-store/routing-forms/pages/routing-link/[...appPages].tsx b/packages/app-store/routing-forms/pages/routing-link/[...appPages].tsx
index 7ed5e4b9d7..5d7c2035fe 100644
--- a/packages/app-store/routing-forms/pages/routing-link/[...appPages].tsx
+++ b/packages/app-store/routing-forms/pages/routing-link/[...appPages].tsx
@@ -6,6 +6,7 @@ import { Toaster } from "react-hot-toast";
import { v4 as uuidv4 } from "uuid";
import { sdkActionManager, useIsEmbed } from "@calcom/embed-core/embed-iframe";
+import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
import classNames from "@calcom/lib/classNames";
import useGetBrandingColours from "@calcom/lib/getBrandColours";
import { useLocale } from "@calcom/lib/hooks/useLocale";
@@ -246,11 +247,20 @@ export const getServerSideProps = async function getServerSideProps(
notFound: true,
};
}
+ const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(context.req.headers.host ?? "");
+
const isEmbed = params.appPages[1] === "embed";
- const form = await prisma.app_RoutingForms_Form.findUnique({
+ const form = await prisma.app_RoutingForms_Form.findFirst({
where: {
id: formId,
+ user: {
+ organization: isValidOrgDomain
+ ? {
+ slug: currentOrgDomain,
+ }
+ : null,
+ },
},
include: {
user: {
diff --git a/packages/features/ee/organizations/lib/orgDomains.ts b/packages/features/ee/organizations/lib/orgDomains.ts
index 666caea2ed..cc46c400b1 100644
--- a/packages/features/ee/organizations/lib/orgDomains.ts
+++ b/packages/features/ee/organizations/lib/orgDomains.ts
@@ -37,6 +37,5 @@ export function subdomainSuffix() {
}
export function getOrgFullDomain(slug: string, options: { protocol: boolean } = { protocol: true }) {
- // TODO: It is a replacement for WEBAPP_URL and that doesn't have / in the end. Remove / after ensuring that it works reliably everywhere
- return `${options.protocol ? `${new URL(WEBAPP_URL).protocol}//` : ""}${slug}.${subdomainSuffix()}/`;
+ return `${options.protocol ? `${new URL(WEBAPP_URL).protocol}//` : ""}${slug}.${subdomainSuffix()}`;
}
diff --git a/packages/features/ee/teams/components/MemberListItem.tsx b/packages/features/ee/teams/components/MemberListItem.tsx
index 726ba3ff1f..da85f5a94a 100644
--- a/packages/features/ee/teams/components/MemberListItem.tsx
+++ b/packages/features/ee/teams/components/MemberListItem.tsx
@@ -2,7 +2,7 @@ import classNames from "classnames";
import { signIn } from "next-auth/react";
import { useState } from "react";
-import { WEBAPP_URL } from "@calcom/lib/constants";
+import { useBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { MembershipRole } from "@calcom/prisma/enums";
import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
@@ -108,8 +108,9 @@ export default function MemberListItem(props: Props) {
props.member.accepted &&
process.env.NEXT_PUBLIC_TEAM_IMPERSONATION === "true";
- const urlWithoutProtocol = WEBAPP_URL.replace(/^https?:\/\//, "");
- const bookingLink = !!props.member.username && `${urlWithoutProtocol}/${props.member.username}`;
+ const bookerUrl = useBookerUrl();
+ const bookerUrlWithoutProtocol = bookerUrl.replace(/^https?:\/\//, "");
+ const bookingLink = !!props.member.username && `${bookerUrlWithoutProtocol}/${props.member.username}`;
return (
@@ -118,7 +119,7 @@ export default function MemberListItem(props: Props) {
@@ -139,7 +140,7 @@ export default function MemberListItem(props: Props) {
•
{bookingLink}
@@ -170,7 +171,7 @@ export default function MemberListItem(props: Props) {