-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
163 lines (152 loc) · 5.34 KB
/
next.config.js
File metadata and controls
163 lines (152 loc) · 5.34 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/** @type {import('next').NextConfig} */
// Content Security Policy configuration
const cspDirectives = {
"default-src": "'self'",
"script-src":
"'self' 'unsafe-inline' 'unsafe-eval' https://connect.facebook.net https://vercel.live https://va.vercel-scripts.com https://vercel.app https://*.clerk.accounts.dev https://*.clerk.dev https://www.google.com https://www.gstatic.com https://www.recaptcha.net https://recaptcha.net https://js.hcaptcha.com https://hcaptcha.com https://challenges.cloudflare.com https://cdn.jsdelivr.net https://unpkg.com",
"style-src":
"'self' 'unsafe-inline' https://www.google.com https://www.gstatic.com https://hcaptcha.com https://challenges.cloudflare.com",
"img-src": "'self' data: https: blob:",
"font-src": "'self' data: https://www.gstatic.com https://fonts.gstatic.com",
"connect-src":
"'self' https://*.supabase.co https://api.supabase.io https://vercel.live https://vercel.app https://*.clerk.accounts.dev https://*.clerk.dev https://api.clerk.com https://www.google.com https://www.recaptcha.net https://recaptcha.net https://hcaptcha.com https://api.hcaptcha.com https://challenges.cloudflare.com https://clerk.com https://clerk-telemetry.com",
"frame-src":
"'self' https://www.facebook.com https://*.clerk.accounts.dev https://*.clerk.dev https://www.google.com https://www.recaptcha.net https://recaptcha.net https://hcaptcha.com https://newassets.hcaptcha.com https://challenges.cloudflare.com https://vercel.live https://*.vercel.live",
"worker-src": "'self' blob:",
"child-src": "'self' blob:",
"object-src": "'none'",
"base-uri": "'self'",
"form-action": "'self'",
"frame-ancestors": "'none'",
};
const cspHeader = Object.entries(cspDirectives)
.map(([directive, value]) => `${directive} ${value}`)
.join("; ");
const nextConfig = {
images: {
remotePatterns: [
{
protocol: "https",
hostname: "img.clerk.com",
port: "",
pathname: "/**",
},
{
protocol: "https",
hostname: "crests.football-data.org",
port: "",
pathname: "/**",
},
],
// Enable image optimization
formats: ["image/avif", "image/webp"],
minimumCacheTTL: 60 * 60 * 24 * 30, // 30 days
deviceSizes: [640, 750, 828, 1080, 1200, 1920],
imageSizes: [16, 32, 48, 64, 96, 128, 256],
},
async headers() {
return [
{
source: "/(.*)",
headers: [
{
key: "Content-Security-Policy",
value: cspHeader,
},
{
key: "X-Content-Type-Options",
value: "nosniff",
},
{
key: "X-Frame-Options",
value: "DENY",
},
{
key: "X-XSS-Protection",
value: "1; mode=block",
},
{
key: "Referrer-Policy",
value: "strict-origin-when-cross-origin",
},
{
key: "Permissions-Policy",
value: "camera=(), microphone=(), geolocation=()",
},
{
key: "Strict-Transport-Security",
value: "max-age=31536000; includeSubDomains; preload",
},
],
},
// Static assets caching
{
source: "/images/:path*",
headers: [
{
key: "Cache-Control",
value: "public, max-age=31536000, immutable",
},
],
},
{
source: "/_next/static/:path*",
headers: [
{
key: "Cache-Control",
value: "public, max-age=31536000, immutable",
},
],
},
{
source: "/fonts/:path*",
headers: [
{
key: "Cache-Control",
value: "public, max-age=31536000, immutable",
},
],
},
];
},
// Security improvements
poweredByHeader: false,
reactStrictMode: true,
// Performance optimizations
compiler: {
removeConsole: process.env.NODE_ENV === "production",
},
// Only enable source maps in production if needed for debugging
productionBrowserSourceMaps: false,
experimental: {
optimizePackageImports: [
"lucide-react",
"date-fns",
"@clerk/nextjs",
"@supabase/supabase-js",
"@sentry/nextjs",
"zod",
],
},
};
const { withSentryConfig } = require("@sentry/nextjs");
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});
module.exports = withBundleAnalyzer(withSentryConfig(nextConfig, {
// For all available options, see: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
// Upload a larger amount of data to Sentry
widenClientFileUpload: true,
// Transpiles SDK to be compatible with older browsers.
// Remove this if you only support modern browsers
transpileClientSDK: true,
// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
// This can't be configured when a custom `server.dev.url` is set in the Sentry config.
tunnelRoute: "/monitoring-tunnel",
// Hides source maps from generated client bundles.
hideSourceMaps: true,
// Automatically tree-shake Sentry SDKs to optimize bundle size.
autoInstrumentServerFunctions: true,
autoInstrumentClientFunctions: true,
// For all available options, see: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
}));