-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.mjs
More file actions
44 lines (41 loc) · 1004 Bytes
/
Copy pathnext.config.mjs
File metadata and controls
44 lines (41 loc) · 1004 Bytes
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
/** @type {import('next').NextConfig} */
const cspHeader = `
default-src 'self';
img-src 'self' data:;
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://www.google.com https://www.gstatic.com;
style-src 'self' 'unsafe-inline';
connect-src 'self' https://earthquake.usgs.gov;
worker-src 'self' blob:;
frame-src 'self' https://www.google.com;
font-src 'self';
object-src 'self';
base-uri 'self';
form-action 'self';
frame-ancestors 'self';
`;
const isProduction = process.env.NODE_ENV === "production";
const securityHeaders = [
{
key: "Content-Security-Policy",
value: cspHeader.replaceAll("\n", "").trim(),
},
...(isProduction
? [
{
key: "Strict-Transport-Security",
value: "max-age=31536000; includeSubDomains",
},
]
: []),
];
const nextConfig = {
headers: async () => {
return [
{
source: "/(.*)",
headers: securityHeaders,
},
];
},
};
export default nextConfig;