mirror of
https://github.com/langgenius/dify.git
synced 2026-04-27 19:27:23 +08:00
refactor: update Content Security Policy to include 'strict-dynamic' and improve nonce handling in Google Analytics component
This commit is contained in:
parent
66bca831cc
commit
c200bbb9fc
@ -24,7 +24,8 @@ const GA: FC<IGAProps> = ({
|
|||||||
if (IS_CE_EDITION)
|
if (IS_CE_EDITION)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
const nonce = process.env.NODE_ENV === 'production' ? (headers() as unknown as UnsafeUnwrappedHeaders).get('x-nonce') ?? '' : ''
|
const nonceValue = process.env.NODE_ENV === 'production' ? (headers() as unknown as UnsafeUnwrappedHeaders).get('x-nonce') : null
|
||||||
|
const nonce = nonceValue || undefined
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -40,20 +41,20 @@ const GA: FC<IGAProps> = ({
|
|||||||
window.gtag('config', '${gaIdMaps[gaType]}');
|
window.gtag('config', '${gaIdMaps[gaType]}');
|
||||||
`,
|
`,
|
||||||
}}
|
}}
|
||||||
nonce={nonce ?? undefined}
|
nonce={nonce}
|
||||||
/>
|
/>
|
||||||
{/* Load GA script */}
|
{/* Load GA script */}
|
||||||
<Script
|
<Script
|
||||||
strategy="afterInteractive"
|
strategy="afterInteractive"
|
||||||
src={`https://www.googletagmanager.com/gtag/js?id=${gaIdMaps[gaType]}`}
|
src={`https://www.googletagmanager.com/gtag/js?id=${gaIdMaps[gaType]}`}
|
||||||
nonce={nonce ?? undefined}
|
nonce={nonce}
|
||||||
/>
|
/>
|
||||||
{/* Cookie banner */}
|
{/* Cookie banner */}
|
||||||
<Script
|
<Script
|
||||||
id="cookieyes"
|
id="cookieyes"
|
||||||
strategy="lazyOnload"
|
strategy="lazyOnload"
|
||||||
src='https://cdn-cookieyes.com/client_data/2a645945fcae53f8e025a2b1/script.js'
|
src='https://cdn-cookieyes.com/client_data/2a645945fcae53f8e025a2b1/script.js'
|
||||||
nonce={nonce ?? undefined}
|
nonce={nonce}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user