Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 95c125f

Browse files
committed
Update content security header for Google Analytics 4
1 parent c886dc2 commit 95c125f

File tree

3 files changed

+17
-34
lines changed

3 files changed

+17
-34
lines changed

angular.json

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@
6969
}
7070
],
7171
"stylePreprocessorOptions": {
72-
"includePaths": [
73-
"node_modules",
74-
"src",
75-
"src/styles"
76-
]
72+
"includePaths": ["node_modules", "src", "src/styles"]
7773
},
7874
"scripts": [],
7975
"vendorChunk": true,
@@ -110,7 +106,11 @@
110106
"serve": {
111107
"builder": "@angular-devkit/build-angular:dev-server",
112108
"options": {
113-
"browserTarget": "material-angular-io:build"
109+
"browserTarget": "material-angular-io:build",
110+
"headers": {
111+
// Keep in sync with `firebase.json`
112+
"Content-Security-Policy": "upgrade-insecure-requests; default-src 'self'; font-src 'self' https://fonts.gstatic.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' *; frame-src https://www.youtube.com; media-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://*.google-analytics.com https://www.googletagmanager.com; child-src 'self' blob:; connect-src 'self' https://material.angular.io https://*.google-analytics.com https://stats.g.doubleclick.net https://api.github.com https://www.googletagmanager.com;"
113+
}
114114
},
115115
"configurations": {
116116
"production": {
@@ -161,11 +161,7 @@
161161
}
162162
],
163163
"stylePreprocessorOptions": {
164-
"includePaths": [
165-
"node_modules",
166-
"src",
167-
"src/styles"
168-
]
164+
"includePaths": ["node_modules", "src", "src/styles"]
169165
},
170166
"assets": [
171167
{
@@ -184,10 +180,7 @@
184180
"lint": {
185181
"builder": "@angular-eslint/builder:lint",
186182
"options": {
187-
"lintFilePatterns": [
188-
"src/**/*.ts",
189-
"src/**/*.html"
190-
]
183+
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
191184
}
192185
},
193186
"e2e": {
@@ -223,13 +216,8 @@
223216
"main": "scenes/src/main.ts",
224217
"polyfills": "scenes/src/polyfills.ts",
225218
"tsConfig": "scenes/tsconfig.app.json",
226-
"assets": [
227-
"scenes/src/favicon.ico",
228-
"scenes/src/assets"
229-
],
230-
"styles": [
231-
"scenes/src/styles.scss"
232-
],
219+
"assets": ["scenes/src/favicon.ico", "scenes/src/assets"],
220+
"styles": ["scenes/src/styles.scss"],
233221
"scripts": [],
234222
"vendorChunk": true,
235223
"extractLicenses": false,
@@ -292,23 +280,15 @@
292280
"polyfills": "scenes/src/polyfills.ts",
293281
"tsConfig": "scenes/tsconfig.spec.json",
294282
"karmaConfig": "scenes/karma.conf.js",
295-
"assets": [
296-
"scenes/src/favicon.ico",
297-
"scenes/src/assets"
298-
],
299-
"styles": [
300-
"scenes/src/styles.scss"
301-
],
283+
"assets": ["scenes/src/favicon.ico", "scenes/src/assets"],
284+
"styles": ["scenes/src/styles.scss"],
302285
"scripts": []
303286
}
304287
},
305288
"lint": {
306289
"builder": "@angular-eslint/builder:lint",
307290
"options": {
308-
"lintFilePatterns": [
309-
"scenes/**/*.ts",
310-
"scenes/**/*.html"
311-
]
291+
"lintFilePatterns": ["scenes/**/*.ts", "scenes/**/*.html"]
312292
}
313293
},
314294
"e2e": {

firebase.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
},
4545
{
4646
"key": "Content-Security-Policy",
47-
"value": "upgrade-insecure-requests; default-src 'self'; font-src 'self' https://fonts.gstatic.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' *; frame-src https://www.youtube.com; media-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://www.google-analytics.com; child-src 'self' blob:; connect-src 'self' https://material.angular.io https://www.google-analytics.com https://stats.g.doubleclick.net https://api.github.com;"
47+
// Keep in sync with `angular.json`.
48+
"value": "upgrade-insecure-requests; default-src 'self'; font-src 'self' https://fonts.gstatic.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' *; frame-src https://www.youtube.com; media-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://*.google-analytics.com https://www.googletagmanager.com; child-src 'self' blob:; connect-src 'self' https://material.angular.io https://*.google-analytics.com https://stats.g.doubleclick.net https://api.github.com https://www.googletagmanager.com;"
4849
}
4950
]
5051
},

src/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
<meta name="theme-color" content="#3f51b5">
4848

4949
<link rel="preconnect" href="https://fonts.gstatic.com">
50+
<link rel="dns-prefetch" href="https://www.googletagmanager.com">
51+
5052
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono&family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
5153
<link href="https://fonts.googleapis.com/icon?family=Material+Icons&display=block" rel="stylesheet">
5254

0 commit comments

Comments
 (0)