Scheduling infrastructure for absolutely everyone.
dont install the scripts on booking pages (#20373)
Hariom Balharab0ed1fd5e623
diff --git a/.env.example b/.env.exampleindex de49146b26e..7b68318025f 100644--- a/.env.example+++ b/.env.example@@ -434,4 +434,8 @@ NEXT_PUBLIC_QUERY_AVAILABLE_SLOTS_INTERVAL_SECONDS=# Used to invalidate available slots when navigating to booking formNEXT_PUBLIC_INVALIDATE_AVAILABLE_SLOTS_ON_BOOKING_FORM=0# Used to enable quick availability checks for x% of all visitors-NEXT_PUBLIC_QUICK_AVAILABILITY_ROLLOUT=10\ No newline at end of file+NEXT_PUBLIC_QUICK_AVAILABILITY_ROLLOUT=10++# Deprecated. Use NEXT_PUBLIC_BODY_SCRIPTS instead. NEXT_PUBLIC_HEAD_SCRIPTS are now injected into the body only.+NEXT_PUBLIC_HEAD_SCRIPTS=+NEXT_PUBLIC_BODY_SCRIPTS=\ No newline at end of filediff --git a/apps/web/app/(use-page-wrapper)/layout.tsx b/apps/web/app/(use-page-wrapper)/layout.tsxindex b06a3a5fe6d..761b529d3a8 100644--- a/apps/web/app/(use-page-wrapper)/layout.tsx+++ b/apps/web/app/(use-page-wrapper)/layout.tsx@@ -1,14 +1,39 @@import { headers } from "next/headers";+import Script from "next/script";import PageWrapper from "@components/PageWrapperAppDir";export default async function PageWrapperLayout({ children }: { children: React.ReactNode }) {const h = await headers();const nonce = h.get("x-nonce") ?? undefined;+ const headScript = process.env.NEXT_PUBLIC_HEAD_SCRIPTS;+ const bodyScript = process.env.NEXT_PUBLIC_BODY_SCRIPTS;++ const scripts = [+ {+ id: "injected-head-script",+ script: headScript ?? "",+ },+ {+ id: "injected-body-script",+ script: bodyScript ?? "",+ },+ ].filter((script): script is { id: string; script: string } => !!script.script);return (<PageWrapper requiresLicense={false} nonce={nonce}>{children}+ {scripts.map((script) => (+ <Script+ key={script.id}+ nonce={nonce}+ id={script.id}+ // eslint-disable-next-line react/no-danger+ dangerouslySetInnerHTML={{+ __html: script.script,+ }}+ />+ ))}</PageWrapper>);}diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsxindex 965588fb928..77c67a5d7e3 100644--- a/apps/web/app/layout.tsx+++ b/apps/web/app/layout.tsx@@ -116,16 +116,6 @@ export default async function RootLayout({ children }: { children: React.ReactNosuppressHydrationWarningdata-nextjs-router="app"><head nonce={nonce}>- {!!process.env.NEXT_PUBLIC_HEAD_SCRIPTS && (- <script- nonce={nonce}- id="injected-head-scripts"- // eslint-disable-next-line react/no-danger- dangerouslySetInnerHTML={{- __html: process.env.NEXT_PUBLIC_HEAD_SCRIPTS,- }}- />- )}<style>{`:root {--font-inter: ${interFont.style.fontFamily.replace(/\'/g, "")};@@ -150,16 +140,6 @@ export default async function RootLayout({ children }: { children: React.ReactNo}}><IconSprites />- {!!process.env.NEXT_PUBLIC_BODY_SCRIPTS && (- <script- nonce={nonce}- id="injected-head-scripts"- // eslint-disable-next-line react/no-danger- dangerouslySetInnerHTML={{- __html: process.env.NEXT_PUBLIC_BODY_SCRIPTS,- }}- />- )}<SpeculationRules// URLs In NavigationprerenderPathsOnHover={[