-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
67 lines (62 loc) · 2.27 KB
/
next.config.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
// https://securityheaders.com/
function getSecurityHeaders(isProd) {
const headers = [
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN'
},
{
key: 'X-Content-Type-Options',
value: 'nosniff'
},
{
key: 'Referrer-Policy',
value: 'origin-when-cross-origin'
},
{
// https://www.permissionspolicy.com/
key: 'Permissions-Policy',
value: 'accelerometer=(), autoplay=(), camera=(), cross-origin-isolated=(), display-capture=(), document-domain=(), encrypted-media=(), fullscreen=(), geolocation=(), gyroscope=(), keyboard-map=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), screen-wake-lock=(), sync-xhr=(), usb=(), web-share=(), xr-spatial-tracking=()'
},
{
key: 'X-XSS-Protection',
value: '1; mode=block'
}
];
if (isProd) {
headers.push(
{
key: 'Strict-Transport-Security',
value: 'max-age=31536000'
},
{
// https://report-uri.com/home/generate
// https://csp-evaluator.withgoogle.com/
key: 'Content-Security-Policy',
value: `default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self'; font-src 'self'; object-src 'none'`
}
);
}
return headers;
}
const isProd = process.env['NODE_ENV'] === 'production';
/** @type { import('next').NextConfig } */
const nextConfig = {
// add environment variables accessible via AppSettings here:
// visible only by server-side Next.js (secrets)
// if accessing variables required in browser-side code, use getServerSideProps
// https://nextjs.org/docs/basic-features/data-fetching/get-server-side-props
serverRuntimeConfig: require('./appsettings'),
productionBrowserSourceMaps: true,
reactStrictMode: true,
async headers() {
return [
{
// Apply these headers to all routes in your application.
source: '/:path*',
headers: getSecurityHeaders(isProd),
},
]
},
};
module.exports = nextConfig;