From c975cfdf3f24abfd50e974a51d0b8766f59544a5 Mon Sep 17 00:00:00 2001 From: Tim Cosgrove Date: Tue, 5 Nov 2024 17:24:21 -0800 Subject: [PATCH 1/2] Roll back custom head & document; add nonce to head and nextscript. --- src/pages/_document.tsx | 249 +++++++++++++++++++--------------------- 1 file changed, 116 insertions(+), 133 deletions(-) diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index 94a729449..728ac917c 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -1,148 +1,131 @@ -import Document, { Html, Main, NextScript, Head } from 'next/document' +import { Html, Main, NextScript, Head } from 'next/document' import { GTM_ID } from '@/lib/analytics' import Script from 'next/script' -import React from 'react' -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**' +const Document = () => { + const ASSETS_URL = process.env.NEXT_PUBLIC_ASSETS_URL || '/generated/' + const nonce = '**CSP_NONCE**' - render() { - return ( - - - - - + return ( + + + + + -