-
Notifications
You must be signed in to change notification settings - Fork 10
/
csp.js
35 lines (31 loc) · 1.06 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
/* cspell:disable */
const cspConfig = {
'default-src': ["'self'", 'https:', 'wss:', 'data:', 'blob:'],
'script-src': [
"'self'",
"'unsafe-inline'",
"'unsafe-eval'",
'www.googletagmanager.com/',
'cdn.jsdelivr.net',
'*.vercel-scripts.com',
'*.firefly.land/',
'vercel.live',
'tag.safary.club',
],
'img-src': ["'self'", 'https:', 'data:', 'blob:'],
'style-src': ["'self'", "'unsafe-inline'", 'vercel.live', 'fonts.googleapis.com'],
'worker-src': ["'self'", 'blob:'],
};
// Add Sentry DSN to CSP report-uri
if (process.env.NEXT_PUBLIC_SENTRY_REPORT_URL) {
cspConfig['report-uri'] = [process.env.NEXT_PUBLIC_SENTRY_REPORT_URL];
}
if (process.env.NODE_ENV === 'development') {
Object.entries(cspConfig).forEach(([key, value]) => {
if (key === 'report-uri') return;
value.push('http://localhost:3000', 'ws://localhost:3000');
});
}
export const POLICY_SETTINGS = Object.entries(cspConfig)
.map(([key, value]) => `${key} ${value.join(' ')}`)
.join('; ');