diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 19b68339d..be54cb2ce 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -17,7 +17,7 @@ type AppPropsWithLayout = AppProps & { export function reportWebVitals(metric: object) { // eslint-disable-next-line no-console - console.log(metric) + // console.log(metric) } export default function MyApp({ diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index c070a36fa..94a729449 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -1,126 +1,148 @@ -import { Html, Main, NextScript, Head } from 'next/document' +import Document, { Html, Main, NextScript, Head } from 'next/document' import { GTM_ID } from '@/lib/analytics' import Script from 'next/script' +import React from 'react' -const Document = () => { - const ASSETS_URL = process.env.NEXT_PUBLIC_ASSETS_URL || '/generated/' +class CustomHead extends Head { + getScripts(files) { + const originalScripts = super.getScripts(files) + return originalScripts.map((script) => { + return React.cloneElement(script, { + 'data-nb-nonce': '**CSP_NONCE**', + }) + }) + } +} + +class CustomDocument extends Document { + #ASSETS_URL = process.env.NEXT_PUBLIC_ASSETS_URL || '/generated/' + #nonce = '**CSP_NONCE**' - return ( - -
- - - + render() { + return ( + +