Created
September 11, 2021 11:21
-
-
Save guydumais/a55e66074fc010f6433be078e456be1f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// Next.js libraries | |
import Document, { Html, Head, Main, NextScript } from 'next/document' | |
// Next Strict Content Security Policy | |
import { NextStrictCSP } from 'next-strict-csp' | |
... | |
// Enable Head Strict CSP in production mode only | |
const HeadCSP = process.env.NODE_ENV === 'production' ? NextStrictCSP : Head | |
... | |
// Document component | |
class MyDoc extends Document { | |
render() { | |
return ( | |
<Html> | |
<HeadCSP> | |
{ process.env.NODE_ENV === 'production' && | |
<meta httpEquiv="Content-Security-Policy" /> | |
} | |
... | |
</HeadCSP> | |
<body> | |
... | |
<Main /> | |
<NextScript /> | |
... | |
</body> | |
</Html> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment