-
Notifications
You must be signed in to change notification settings - Fork 1
/
csp.js
74 lines (72 loc) · 1.45 KB
/
csp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// For information on Content Security Policy see https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
// By default, Google, YouTube, Vimeo, Instagram, and Stripe APIs are allowed
const policies = {
"default-src": [
"'self'",
"blob:",
],
"media-src": [
"'self'",
"blob:",
"data:",
"https://facelessui.com"
],
"img-src": [
"'self'",
"data:",
"blob:",
"https://facelessui.com",
"https://maps.gstatic.com",
"*.googletagmanager.com"
],
"style-src": [
"'self'",
"'unsafe-inline'",
"blob:",
"https://fonts.googleapis.com",
"https://fonts.cdnfonts.com"
],
"font-src": [
"'self'",
"data:",
"https://fonts.gstatic.com",
"https://fonts.cdnfonts.com"
],
"frame-src": [
"'self'",
"data:",
"*.youtube.com"
],
"script-src": [
"'self'",
"blob:",
"'unsafe-eval'",
"'unsafe-inline'",
"*.googleapis.com",
"*.youtube.com",
"*.googletagmanager.com",
"*.google-analytics.com"
],
"connect-src": [
"'self'",
"ws:",
"https://facelessui.com",
"*.googletagmanager.com",
"*.google-analytics.com",
"registry.npmjs.org",
"https://api.github.com",
"vitals.vercel-insights.com"
],
"object-src": [
"'self'",
"data:"
],
};
module.exports = Object.entries(policies)
.map(([key, value]) => {
if (Array.isArray(value)) {
return `${key} ${value.join(" ")}`;
}
return "";
})
.join("; ");