import Document, { Html, Head, Main, NextScript } from 'next/document' import Script from 'next/script' class MyDocument extends Document { // https://nextjs.org/docs/pages/building-your-application/routing/custom-document#customizing-renderpage static async getInitialProps (ctx) { const originalRenderPage = ctx.renderPage // Run the React rendering logic synchronously ctx.renderPage = () => originalRenderPage({ // Useful for wrapping the whole react tree enhanceApp: (App) => App, // Useful for wrapping in a per-page basis enhanceComponent: (Component) => Component }) // response is not available on offline page for example const csp = ctx.res?.getHeaders()['content-security-policy'] const nonce = csp ? /nonce-([a-zA-Z0-9]{48})/.exec(csp)?.[1] : undefined const initialProps = await Document.getInitialProps(ctx) return { ...initialProps, nonce } } render () { const { nonce } = this.props return (