1
1
import crypto from 'crypto' ;
2
2
import Document , { Html , Head , Main , NextScript } from 'next/document' ;
3
+ import { ALGOLIA_APP_ID } from '../constants/algolia' ;
3
4
4
5
const cspHashOf = ( text ) => {
5
6
const hash = crypto . createHash ( 'sha256' ) ;
@@ -14,7 +15,8 @@ const ANALYTICS_CSP = {
14
15
'https://aws.demdex.net' ,
15
16
'https://dpm.demdex.net' ,
16
17
'https://cm.everesttech.net' ,
17
- '*.shortbread.aws.dev'
18
+ 'https://prod.tools.shortbread.aws.dev' ,
19
+ 'https://prod.log.shortbread.aws.dev'
18
20
] ,
19
21
img : [
20
22
'https://amazonwebservices.d2.sc.omtrdc.net' ,
@@ -23,8 +25,8 @@ const ANALYTICS_CSP = {
23
25
'https://cm.everesttech.net'
24
26
] ,
25
27
frame : [ 'https://aws.demdex.net' , 'https://dpm.demdex.net' ] ,
26
- script : [ '* .shortbread.aws.dev' ] ,
27
- style : [ '* .shortbread.aws.dev' ]
28
+ script : [ 'https://prod.assets .shortbread.aws.dev' ] ,
29
+ style : [ 'https://prod.assets .shortbread.aws.dev' ]
28
30
} ,
29
31
prod : {
30
32
connect : [
@@ -71,7 +73,7 @@ const getCspContent = (context) => {
71
73
' '
72
74
) } ${ ANALYTICS_CSP . alpha . connect . join (
73
75
' '
74
- ) } https://* .algolia.net https://* .algolianet.com *.amazonaws .com;
76
+ ) } https://${ ALGOLIA_APP_ID } -dsn .algolia.net https://${ ALGOLIA_APP_ID } -1 .algolianet.com https:// ${ ALGOLIA_APP_ID } -2.algolianet.com https:// ${ ALGOLIA_APP_ID } -3.algolianet .com;
75
77
img-src 'self' https://img.shields.io data: ${ ANALYTICS_CSP . all . img . join (
76
78
' '
77
79
) } ${ ANALYTICS_CSP . alpha . img . join ( ' ' ) } ;
@@ -94,7 +96,7 @@ const getCspContent = (context) => {
94
96
' '
95
97
) } ${ ANALYTICS_CSP . prod . connect . join (
96
98
' '
97
- ) } https://* .algolia.net https://* .algolianet.com *.amazonaws .com;
99
+ ) } https://${ ALGOLIA_APP_ID } -dsn .algolia.net https://${ ALGOLIA_APP_ID } -1 .algolianet.com https:// ${ ALGOLIA_APP_ID } -2.algolianet.com https:// ${ ALGOLIA_APP_ID } -3.algolianet .com;
98
100
img-src 'self' https://img.shields.io ${ ANALYTICS_CSP . all . img . join (
99
101
' '
100
102
) } ${ ANALYTICS_CSP . prod . img . join ( ' ' ) } ;
0 commit comments