Skip to content

Commit a11a9e0

Browse files
jacobloganJacob Logan
andauthored
Update headers and CSP value (#7904)
* update security headers * add csp values * move frame-ancestors * remove frame-ancestor from meta * update headers * use double quotes in yml file --------- Co-authored-by: Jacob Logan <[email protected]>
1 parent 9183a63 commit a11a9e0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

customHttp.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ customHeaders:
1212
value: '1; mode=block'
1313
- key: 'X-Content-Type-Options'
1414
value: 'nosniff'
15+
- key: 'Cache-Control'
16+
value: 'no-store, no-cache'
17+
- key: 'Pragma'
18+
value: 'no-cache'
1519
- key: 'Content-Security-Policy'
16-
value: 'upgrade-insecure-requests;'
20+
value: "upgrade-insecure-requests; frame-ancestors 'none';"
1721
# CSP also set in _document.tsx meta tag

src/pages/_document.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ const getCspContent = (context) => {
6262
if (process.env.BUILD_ENV !== 'production') {
6363
return `
6464
default-src 'none';
65+
object-src 'none';
66+
base-uri 'none';
6567
style-src 'self' 'unsafe-inline' ${ANALYTICS_CSP.all.style.join(' ')};
6668
font-src 'self' data:;
6769
frame-src 'self' https://www.youtube-nocookie.com ${ANALYTICS_CSP.all.frame.join(
@@ -85,6 +87,8 @@ const getCspContent = (context) => {
8587
// Have to keep track of CSP inside customHttp.yml as well
8688
return `
8789
default-src 'none';
90+
object-src 'none';
91+
base-uri 'none';
8892
style-src 'self' 'unsafe-inline' ${ANALYTICS_CSP.all.style.join(' ')};
8993
font-src 'self';
9094
frame-src 'self' https://www.youtube-nocookie.com ${ANALYTICS_CSP.all.frame.join(
@@ -102,6 +106,7 @@ const getCspContent = (context) => {
102106
script-src 'self' ${cspInlineScriptHash} ${ANALYTICS_CSP.prod.script.join(
103107
' '
104108
)} ${ANALYTICS_CSP.all.script.join(' ')};
109+
require-trusted-types-for 'script';
105110
`;
106111
};
107112

0 commit comments

Comments
 (0)