fix: New Booker Rewrites (#9557)
* Solve the problem using Next.config.js only * Debug * Avoid infinite rewritees * Apply suggestions from code review * Apply suggestions from code review * Remove stale comments * Update packages/embeds/embed-core/src/embed-iframe.ts
This commit is contained in:
1 parent
66ebf18fa9
commit
344241cfbf
5 files changed
+86
-77
No files matched your search
@@ -5,7 +5,10 @@ export default function EmbedInitIframe() {
|
||||
return;
|
||||
}
|
||||
|
||||
const embedNameSpaceFromQueryParam = new URL(document.URL).searchParams.get("embed");
|
||||
const url = new URL(document.URL);
|
||||
const embedNameSpaceFromQueryParam = url.searchParams.get("embed");
|
||||
const hasEmbedPath = url.pathname.endsWith("/embed");
|
||||
const defaultNamespace = "";
|
||||
|
||||
// Namespace is initially set in query param `embed` but the query param might get lost during soft navigation
|
||||
// So, we also check for the namespace in `window.name` which is set when iframe is created by embed.ts and persists for the duration of iframe's life
|
||||
@@ -17,6 +20,8 @@ export default function EmbedInitIframe() {
|
||||
? embedNameSpaceFromQueryParam
|
||||
: window.name.includes("cal-embed=")
|
||||
? window.name.replace(/cal-embed=(.*)/, "$1").trim()
|
||||
: hasEmbedPath
|
||||
? defaultNamespace // If query param is not there but /embed is used then assume default namespace.
|
||||
: null;
|
||||
|
||||
window.isEmbed = () => {
|
||||
|
||||
@@ -2,7 +2,6 @@ import { useRouter } from "next/router";
|
||||
import type { CSSProperties } from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
import embedInit from "@calcom/embed-core/embed-iframe-init";
|
||||
import type { BookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import type { BookerLayouts } from "@calcom/prisma/zod-utils";
|
||||
|
||||
@@ -439,8 +438,6 @@ function keepParentInformedAboutDimensionChanges() {
|
||||
|
||||
if (isBrowser) {
|
||||
log("Embed SDK loaded", { isEmbed: window?.isEmbed?.() || false });
|
||||
// Exposes certain global variables/fns that are used by the app to get interface with the embed.
|
||||
embedInit();
|
||||
const url = new URL(document.URL);
|
||||
embedStore.theme = window?.getEmbedTheme?.();
|
||||
if (url.searchParams.get("prerender") !== "true" && window?.isEmbed?.()) {
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
* @file
|
||||
* This module is supposed to instantiate the SDK with appropriate namespace
|
||||
*/
|
||||
import embedInit from "@calcom/embed-core/embed-iframe-init";
|
||||
|
||||
import { SdkActionManager } from "./sdk-action-manager";
|
||||
|
||||
export let sdkActionManager: SdkActionManager | null = null;
|
||||
if (typeof window !== "undefined") {
|
||||
sdkActionManager = new SdkActionManager(new URL(document.URL).searchParams.get("embed"));
|
||||
embedInit();
|
||||
sdkActionManager = new SdkActionManager(window.getEmbedNamespace());
|
||||
}
|
||||
Reference in new issue
Block a user