/
next.config.js
108 lines (99 loc) · 2.32 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
const {
NODE_ENV = 'development',
VERCEL_ENV = NODE_ENV,
VERCEL_URL = 'localhost:3000',
HOSTNAME = `http${/local/.test(VERCEL_URL) ? '' : 's'}://${VERCEL_URL}`,
NON_PROD = VERCEL_ENV !== 'production',
VERCEL_GIT_COMMIT_SHA = Date.now()
} = process.env
const nonProd = `${NON_PROD}` === 'true'
module.exports = {
compiler: { styledComponents: true },
devIndicators: { buildActivity: false },
eslint: { ignoreDuringBuilds: true },
generateBuildId: async () => VERCEL_GIT_COMMIT_SHA,
async headers() {
const baseHeaders = [
{
key: 'Cache-Control',
value: 'max-age=31536000, immutable'
},
{
key: 'X-Host',
value: HOSTNAME
},
{
key: 'X-Robots-Tag',
value: nonProd ? 'none' : 'all'
},
{
key: 'X-XSS-Protection',
value: '1; mode=block'
},
{
key: 'X-Content-Type-Options',
value: 'nosniff'
},
{
key: 'Strict-Transport-Policy',
value: 'max-age=31536000; includeSubdomains; preload'
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN'
},
{
key: 'X-Download-Options',
value: 'noopen'
}
]
if (!nonProd) {
baseHeaders.push({
key: 'Content-Security-Policy',
value: [
"default-src 'self' data: https:",
"font-src 'self' data: https:",
"frame-src 'self' https:",
"img-src 'self' data: https:",
"manifest-src 'self'",
"object-src 'none'",
"script-src 'self' 'unsafe-inline' 'unsafe-eval' https:",
"style-src 'self' 'unsafe-inline' https:"
].join('; ')
})
}
return [
{
headers: [
...baseHeaders,
{
key: 'X-Page',
value: '/'
}
],
source: '/'
},
{
headers: [
{
key: 'Service-Worker-Allowed',
value: '/'
}
],
source: '/service-worker.js'
}
]
},
images: { formats: ['image/avif', 'image/webp'] },
poweredByHeader: false,
reactStrictMode: true,
swcMinify: true,
typescript: { ignoreBuildErrors: true },
webpack(cfg) {
cfg.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack']
})
return cfg
}
}