-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
89 lines (80 loc) · 3.15 KB
/
Copy pathnext.config.ts
File metadata and controls
89 lines (80 loc) · 3.15 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
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
import type { NextConfig } from "next";
import createBundleAnalyzer from "@next/bundle-analyzer";
const withBundleAnalyzer = createBundleAnalyzer({
enabled: process.env.ANALYZE === "true",
});
const nextConfig: NextConfig = {
reactStrictMode: false,
// Compress all responses with gzip/brotli
compress: true,
// Tree-shake large icon/animation libraries to only include used exports
experimental: {
optimizePackageImports: [
"lucide-react",
"@tabler/icons-react",
"react-icons",
"framer-motion",
"motion",
],
},
// Next.js Image optimisation — serve AVIF then WebP, cache 1 year
images: {
qualities: [75, 100],
formats: ["image/avif", "image/webp"],
minimumCacheTTL: 31536000, // 1 year in seconds
deviceSizes: [360, 480, 640, 750, 828, 1080, 1200, 1920, 2048],
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
remotePatterns: [
{ protocol: "https", hostname: "images.unsplash.com" },
{ protocol: "https", hostname: "img.icons8.com" },
{ protocol: "https", hostname: "www.chaosgroup.com" },
{ protocol: "https", hostname: "enscape3d.com" },
{ protocol: "https", hostname: "www.csiamerica.com" },
{ protocol: "https", hostname: "lumion.com" },
{ protocol: "https", hostname: "cdn.simpleicons.org" },
{ protocol: "https", hostname: "upload.wikimedia.org" },
],
},
async headers() {
const securityHeaders = [
{
key: 'X-DNS-Prefetch-Control',
value: 'on'
},
{
key: 'Strict-Transport-Security',
value: 'max-age=63072000; includeSubDomains; preload'
},
{
key: 'X-XSS-Protection',
value: '1; mode=block'
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN'
},
{
key: 'X-Content-Type-Options',
value: 'nosniff'
},
{
key: 'Referrer-Policy',
value: 'origin-when-cross-origin'
},
{
key: 'Content-Security-Policy',
value: process.env.NODE_ENV === 'development'
? "default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' blob: data: https://images.unsplash.com https://img.icons8.com https://www.chaosgroup.com https://enscape3d.com https://www.csiamerica.com https://lumion.com https://cdn.simpleicons.org https://upload.wikimedia.org; font-src 'self' data:; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none';"
: "default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' blob: data: https://images.unsplash.com https://img.icons8.com https://www.chaosgroup.com https://enscape3d.com https://www.csiamerica.com https://lumion.com https://cdn.simpleicons.org https://upload.wikimedia.org; font-src 'self' data:; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests;"
}
];
return [
{
// Apply these headers to all routes
source: '/(.*)',
headers: securityHeaders,
},
];
},
};
export default withBundleAnalyzer(nextConfig);