File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
src/components/DocumentView Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 1
1
import * as gitbookAPI from '@gitbook/api' ;
2
+ import { headers } from 'next/headers' ;
2
3
import Script from 'next/script' ;
3
4
import ReactDOM from 'react-dom' ;
4
5
@@ -12,8 +13,9 @@ import { IntegrationBlock } from './Integration';
12
13
13
14
export async function Embed ( props : BlockProps < gitbookAPI . DocumentBlockEmbed > ) {
14
15
const { block, context, ...otherProps } = props ;
16
+ const nonce = headers ( ) . get ( 'x-nonce' ) || undefined ;
15
17
16
- ReactDOM . preconnect ( 'https://cdn.iframe.ly' ) ;
18
+ ReactDOM . preload ( 'https://cdn.iframe.ly/embed.js' , { as : 'script' , nonce } ) ;
17
19
18
20
const { data : embed } = await ( context . content
19
21
? api ( ) . spaces . getEmbedByUrlInSpace ( context . content . spaceId , { url : block . data . url } )
@@ -28,8 +30,7 @@ export async function Embed(props: BlockProps<gitbookAPI.DocumentBlockEmbed>) {
28
30
__html : embed . html ,
29
31
} }
30
32
/>
31
- { /* We load the iframely script to resize the embed iframes dynamically */ }
32
- < Script src = "https://cdn.iframe.ly/embed.js" defer async />
33
+ < Script src = "https://cdn.iframe.ly/embed.js" nonce = { nonce } />
33
34
</ >
34
35
) : embed . type === 'integration' ? (
35
36
< IntegrationBlock
You can’t perform that action at this time.
0 commit comments