mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
1c817d2bbf
When implementing a strict CSP with nonces and `strict-dynamic`, every script and preload requires a nonce. https://csp.withgoogle.com/docs/strict-csp.html
25 lines
704 B
JavaScript
25 lines
704 B
JavaScript
import Document, { Head, Main, NextScript } from 'next/document'
|
|
|
|
export default class MyDocument extends Document {
|
|
static async getInitialProps (ctx) {
|
|
const initialProps = await Document.getInitialProps(ctx)
|
|
return { ...initialProps, customProperty: 'Hello Document' }
|
|
}
|
|
|
|
render () {
|
|
return (
|
|
<html>
|
|
<Head nonce='test-nonce'>
|
|
<style>{`body { margin: 0 } /* custom! */`}</style>
|
|
</Head>
|
|
<body className='custom_class'>
|
|
<p id='custom-property'>{this.props.customProperty}</p>
|
|
<p id='document-hmr'>Hello Document HMR</p>
|
|
<Main />
|
|
<NextScript nonce='test-nonce' />
|
|
</body>
|
|
</html>
|
|
)
|
|
}
|
|
}
|