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,7 @@ 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.assets.shortbread.aws.dev https://prod.tools.shortbread.aws https://prod.tools .shortbread.aws.dev'
18
19
] ,
19
20
img : [
20
21
'https://amazonwebservices.d2.sc.omtrdc.net' ,
@@ -23,8 +24,12 @@ const ANALYTICS_CSP = {
23
24
'https://cm.everesttech.net'
24
25
] ,
25
26
frame : [ 'https://aws.demdex.net' , 'https://dpm.demdex.net' ] ,
26
- script : [ '*.shortbread.aws.dev' ] ,
27
- style : [ '*.shortbread.aws.dev' ]
27
+ script : [
28
+ 'https://prod.assets.shortbread.aws.dev https://prod.tools.shortbread.aws https://prod.log.shortbread.aws.dev'
29
+ ] ,
30
+ style : [
31
+ 'https://prod.assets.shortbread.aws.dev https://prod.tools.shortbread.aws https://prod.log.shortbread.aws.dev'
32
+ ]
28
33
} ,
29
34
prod : {
30
35
connect : [
@@ -71,7 +76,7 @@ const getCspContent = (context) => {
71
76
' '
72
77
) } ${ ANALYTICS_CSP . alpha . connect . join (
73
78
' '
74
- ) } https://* .algolia.net https://* .algolianet.com *.amazonaws .com;
79
+ ) } 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
80
img-src 'self' https://img.shields.io data: ${ ANALYTICS_CSP . all . img . join (
76
81
' '
77
82
) } ${ ANALYTICS_CSP . alpha . img . join ( ' ' ) } ;
@@ -94,7 +99,7 @@ const getCspContent = (context) => {
94
99
' '
95
100
) } ${ ANALYTICS_CSP . prod . connect . join (
96
101
' '
97
- ) } https://* .algolia.net https://* .algolianet.com *.amazonaws .com;
102
+ ) } 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
103
img-src 'self' https://img.shields.io ${ ANALYTICS_CSP . all . img . join (
99
104
' '
100
105
) } ${ ANALYTICS_CSP . prod . img . join ( ' ' ) } ;
0 commit comments