From a790dfa8de2b09c4ea1d7868ee2a14acc015436e Mon Sep 17 00:00:00 2001 From: Chenalejandro <65429905+Chenalejandro@users.noreply.github.com> Date: Tue, 16 Jul 2024 17:16:29 -0300 Subject: [PATCH] Allowing passing a nonce to inline-scripts/inline-styles to have better support for csp (#134) Signed-off-by: alejandro --- .../src/components/elements/ssr-layout-effect.tsx | 10 ++++++++-- packages/stack/src/providers/theme-provider.tsx | 12 ++++++++++-- packages/stack/src/utils/browser-script.tsx | 4 ++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/packages/stack/src/components/elements/ssr-layout-effect.tsx b/packages/stack/src/components/elements/ssr-layout-effect.tsx index db7273223..53e08ce05 100644 --- a/packages/stack/src/components/elements/ssr-layout-effect.tsx +++ b/packages/stack/src/components/elements/ssr-layout-effect.tsx @@ -1,7 +1,7 @@ "use client"; import { useLayoutEffect } from "react"; -export function SsrScript(props: { script: string }) { +export function SsrScript(props: { script: string, nonce?: string }) { useLayoutEffect(() => { // TODO fix workaround: React has a bug where it doesn't run the script on the first CSR render if SSR has been skipped due to suspense // As a workaround, we run the script in the