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 11import * as gitbookAPI from '@gitbook/api' ;
2+ import { headers } from 'next/headers' ;
23import Script from 'next/script' ;
34import ReactDOM from 'react-dom' ;
45
@@ -12,8 +13,9 @@ import { IntegrationBlock } from './Integration';
1213
1314export async function Embed ( props : BlockProps < gitbookAPI . DocumentBlockEmbed > ) {
1415 const { block, context, ...otherProps } = props ;
16+ const nonce = headers ( ) . get ( 'x-nonce' ) || undefined ;
1517
16- ReactDOM . preconnect ( 'https://cdn.iframe.ly' ) ;
18+ ReactDOM . preload ( 'https://cdn.iframe.ly/embed.js' , { as : 'script' , nonce } ) ;
1719
1820 const { data : embed } = await ( context . content
1921 ? api ( ) . spaces . getEmbedByUrlInSpace ( context . content . spaceId , { url : block . data . url } )
@@ -28,8 +30,7 @@ export async function Embed(props: BlockProps<gitbookAPI.DocumentBlockEmbed>) {
2830 __html : embed . html ,
2931 } }
3032 />
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 } />
3334 </ >
3435 ) : embed . type === 'integration' ? (
3536 < IntegrationBlock
You can’t perform that action at this time.
0 commit comments