-
Notifications
You must be signed in to change notification settings - Fork 0
/
helmet.js
50 lines (49 loc) · 1.2 KB
/
helmet.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
const { generateNonce } = require("./strings");
module.exports = {
contentSecurityPolicy: {
directives: {
defaultSrc: ["'self'"],
styleSrc: ["'self'"],
scriptSrc: [
"'self'",
(req, res) => {
res.locals.cspNonce = res.locals.cspNonce || generateNonce();
return `'nonce-${res.locals.cspNonce}'`;
},
"'sha256-+6WnXIl4mbFTCARd8N3COQmT3bJJmo32N8q8ZSQAIcU='",
"https://www.googletagmanager.com",
"https://www.google-analytics.com",
"https://ssl.google-analytics.com",
],
imgSrc: [
"'self'",
"data:",
"https://www.googletagmanager.com",
"*.google-analytics.com",
"*.analytics.google.com",
],
formAction: ["*"],
objectSrc: ["'none'"],
connectSrc: [
"'self'",
"*.google-analytics.com",
"*.analytics.google.com",
],
},
},
dnsPrefetchControl: {
allow: false,
},
frameguard: {
action: "deny",
},
hsts: {
maxAge: 31536000, // 1 Year
preload: true,
includeSubDomains: true,
},
referrerPolicy: false,
permittedCrossDomainPolicies: false,
expectCt: false,
crossOriginEmbedderPolicy: false,
};