-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Expand file tree
/
Copy pathnext.config.ts
More file actions
57 lines (50 loc) · 1.17 KB
/
next.config.ts
File metadata and controls
57 lines (50 loc) · 1.17 KB
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
import type { NextConfig } from "next";
const IS_DEV = process.env.NODE_ENV !== "production";
const CSP = [
"default-src 'self';",
"script-src 'self' 'unsafe-eval' 'unsafe-inline' ;",
"connect-src 'self';",
"style-src 'self' 'unsafe-inline';",
"img-src 'self'",
"object-src 'none';",
"frame-ancestors 'none';",
IS_DEV ? null : "upgrade-insecure-requests;",
]
.filter(Boolean)
.join(" ");
const nextConfig: NextConfig = {
turbopack: {
rules: {
"*.svg": {
loaders: ["@svgr/webpack"],
as: "*.js",
},
},
},
devIndicators: false,
// Apply the same SVG transform to the webpack-based production build
webpack(config) {
config.module.rules.push({
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: ["@svgr/webpack"],
});
return config;
},
async headers() {
const headers = [
{
key: "Content-Security-Policy",
value: CSP,
},
];
if (!IS_DEV) {
headers.push({
key: "Strict-Transport-Security",
value: "max-age=31536000; includeSubDomains; preload",
});
}
return [{ source: "/(.*)", headers }];
},
};
export default nextConfig;