-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathcsp.ts
More file actions
66 lines (64 loc) · 1.72 KB
/
csp.ts
File metadata and controls
66 lines (64 loc) · 1.72 KB
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
const cspDirectives = {
'default-src': ["'self'"],
'script-src': [
"'self'",
"'unsafe-eval'",
"'unsafe-inline'",
'https://www.googletagmanager.com',
'https://www.google-analytics.com',
'https://analytics.google.com',
'https://client.axept.io',
'https://api.axept.io',
'https://static.axept.io',
'https://cdn.jsdelivr.net',
'https://vercel.live',
],
'style-src': [
"'self'",
"'unsafe-inline'",
'https://www.googletagmanager.com',
'https://fonts.googleapis.com',
],
'font-src': ["'self'", 'https://fonts.gstatic.com'],
'img-src': [
"'self'",
'data:',
'blob:',
'https://www.googletagmanager.com',
'https://www.google-analytics.com',
'https://analytics.google.com',
'https://axeptio.imgix.net',
],
'media-src': ["'self'", 'blob:'],
'connect-src': [
"'self'",
'https://www.google-analytics.com',
'https://region1.google-analytics.com',
'https://analytics.google.com',
'https://www.googletagmanager.com',
'https://client.axept.io',
'https://static.axept.io',
'https://api.axept.io',
'https://esm.sh',
],
'frame-src': [
"'self'",
'https://www.youtube.com',
'https://www.youtube-nocookie.com',
'https://player.vimeo.com',
'https://vercel.live/'
],
'worker-src': ["'self'", 'blob:'],
'object-src': ["'none'"],
'base-uri': ["'self'"],
'form-action': ["'self'"],
'frame-ancestors': ["'none'"],
'upgrade-insecure-requests': [],
} as const;
export const cspHeader = Object.entries(cspDirectives)
.map(([key, values]) =>
values.length > 0 ? `${key} ${values.join(' ')}` : key
)
.join('; ');
// For use in next.config.ts headers
export const getCspHeaderValue = () => cspHeader;