Security Headers | Next.js
Next.js 12.0.1です。
配列の中に上のリストを入れます。
1const securityHeaders = [
2 {
3 key: 'X-DNS-Prefetch-Control',
4 value: 'on',
5 },
6
7
8 {
9 key: 'X-XSS-Protection',
10 value: '1; mode=block',
11 },
12
13
14 {
15 key: 'X-Frame-Options',
16 value: 'SAMEORIGIN',
17 },
18
19
20 {
21 key: 'X-Content-Type-Options',
22 value: 'nosniff',
23 },
24
25
26 {
27 key: 'Referrer-Policy',
28 value: 'strict-origin-when-cross-origin',
29 },
30
31
32 {
33 key: 'Content-Security-Policy',
34 value: 'self',
35 }
36]
37
38
39module.exports = {
40 swcMinify: true,
41 async headers() {
42 return [
43 {
44 source: '/(.*)',
45 headers: securityHeaders,
46 },
47 ]
48 },
49}