-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
324 lines (313 loc) · 8.63 KB
/
next.config.ts
File metadata and controls
324 lines (313 loc) · 8.63 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
import type { NextConfig } from "next";
const isProduction = process.env.VERCEL_ENV === "production";
// Vercel automatically sets this environment variable during builds
const isVercel = !!process.env.VERCEL;
const nextConfig: NextConfig = {
reactStrictMode: true,
// Only use standalone output for non-Vercel deployments (e.g., Docker/self-hosting)
// Vercel has its own optimized build system and doesn't support standalone mode
// This will automatically be omitted when building on Vercel
...(isVercel ? {} : { output: "standalone" }),
trailingSlash: true,
compress: true, // Enable gzip compression
poweredByHeader: false, // Remove X-Powered-By header
images: {
remotePatterns: [
{
protocol: "https",
hostname: "www.notion.so",
},
{
protocol: "https",
hostname: "notion.so",
},
{
protocol: "https",
hostname: "media-bucket24.s3.us-east-1.amazonaws.com",
},
{
protocol: "https",
hostname: "ipapi.co",
},
{
protocol: "https",
hostname: "images.unsplash.com",
},
],
unoptimized: false, // Enable image optimization
formats: ["image/webp", "image/avif"],
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
minimumCacheTTL: 31536000, // 1 year cache for images
},
// Performance optimizations
experimental: {
optimizeCss: true,
optimizePackageImports: ["framer-motion", "lucide-react", "react-icons"],
},
// Security and performance headers
async headers() {
const headers = [
{
source: "/(.*)",
headers: [
{
key: "X-Frame-Options",
value: "DENY",
},
{
key: "X-Content-Type-Options",
value: "nosniff",
},
{
key: "Referrer-Policy",
value: "strict-origin-when-cross-origin",
},
{
key: "Permissions-Policy",
value: "camera=(), microphone=(), geolocation=()",
},
],
},
// HTML pages - no cache in dev, proper cache in production
// Note: Removed this header rule as it might interfere with client-side navigation
// Next.js handles caching internally for client-side navigation
...(isProduction
? [
{
source:
"/(.*\\.html|/|/about|/contact|/services|/blog|/agent|/ai-clarity-workshop|/thankyou)",
headers: [
{
key: "Cache-Control",
value:
"public, max-age=3600, s-maxage=86400, stale-while-revalidate=31536000",
},
],
},
]
: []),
// Static assets - long cache (production only)
...(isProduction
? [
{
source: "/_next/static/(.*)",
headers: [
{
key: "Cache-Control",
value: "public, max-age=31536000, immutable",
},
],
},
{
source: "/static/(.*)",
headers: [
{
key: "Cache-Control",
value: "public, max-age=31536000, immutable",
},
],
},
// Font files - long cache
{
source: "/(.*\\.woff2|.*\\.woff|.*\\.ttf|.*\\.otf)",
headers: [
{
key: "Cache-Control",
value: "public, max-age=31536000, immutable",
},
],
},
// Images - long cache
{
source:
"/(.*\\.jpg|.*\\.jpeg|.*\\.png|.*\\.gif|.*\\.webp|.*\\.avif|.*\\.svg)",
headers: [
{
key: "Cache-Control",
value: "public, max-age=31536000, immutable",
},
],
},
// JavaScript and CSS - long cache with versioning
{
source: "/(.*\\.js|.*\\.css)",
headers: [
{
key: "Cache-Control",
value: "public, max-age=31536000, immutable",
},
],
},
]
: []),
// API routes - no cache
{
source: "/api/(.*)",
headers: [
{
key: "Cache-Control",
value: "no-cache, no-store, must-revalidate",
},
],
},
];
// Add noindex headers for non-production environments
// if (!isProduction) {
// headers.push({
// source: "/(.*)",
// headers: [
// {
// key: "X-Robots-Tag",
// value: "noindex, nofollow",
// },
// ],
// });
// }
return headers;
},
// Webpack optimizations
// webpack: (config, { dev, isServer }) => {
// // Optimize bundle size
// if (!dev && !isServer) {
// config.optimization.splitChunks = {
// chunks: "all",
// cacheGroups: {
// vendor: {
// test: /[\\/]node_modules[\\/]/,
// name: "vendors",
// chunks: "all",
// priority: 10,
// },
// framer: {
// test: /[\\/]node_modules[\\/]framer-motion[\\/]/,
// name: "framer-motion",
// chunks: "all",
// priority: 20,
// },
// react: {
// test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
// name: "react",
// chunks: "all",
// priority: 30,
// },
// icons: {
// test: /[\\/]node_modules[\\/](react-icons|lucide-react)[\\/]/,
// name: "icons",
// chunks: "all",
// priority: 25,
// },
// common: {
// name: "common",
// minChunks: 2,
// chunks: "all",
// priority: 5,
// reuseExistingChunk: true,
// },
// },
// };
// // Enable tree shaking
// config.optimization.usedExports = true;
// config.optimization.sideEffects = false;
// // Enable module concatenation
// config.optimization.concatenateModules = true;
// // Optimize module resolution
// config.resolve.modules = ["node_modules"];
// config.resolve.extensions = [".tsx", ".ts", ".jsx", ".js"];
// // Remove unused code
// config.optimization.minimize = true;
// }
// // Optimize SVG handling
// config.module.rules.push({
// test: /\.svg$/,
// use: ["@svgr/webpack"],
// });
// return config;
// },
// Redirects to avoid multiple page redirects
async redirects() {
return [
{
source: "/home",
destination: "/",
permanent: true,
},
{
source: "/home/",
destination: "/",
permanent: true,
},
{
source: "/index",
destination: "/",
permanent: true,
},
{
source: "/index/",
destination: "/",
permanent: true,
},
// Pricing page → hub pricing section
{
source: "/ai-voice-agent-pricing",
destination: "/ai-voice-agent/#pricing",
permanent: false,
},
{
source: "/ai-voice-agent-pricing/",
destination: "/ai-voice-agent/#pricing",
permanent: false,
},
// Localized routes redirects to global
{
source: "/en-in/:path*",
destination: "/:path*",
permanent: true,
},
{
source: "/en-us/:path*",
destination: "/:path*",
permanent: true,
},
{
source: "/en-ca/:path*",
destination: "/:path*",
permanent: true,
},
{
source: "/en-au/:path*",
destination: "/:path*",
permanent: true,
},
{
source: "/en-ae/:path*",
destination: "/:path*",
permanent: true,
},
{
source: "/en-gb/:path*",
destination: "/:path*",
permanent: true,
},
];
},
// Rewrites for external API calls and Partytown
async rewrites() {
return [
{
source: "/api/geolocation",
destination: "https://ipapi.co/json/",
},
// Partytown web worker files
{
source: "/~partytown/:path*",
destination: "/node_modules/@builder.io/partytown/lib/:path*",
},
];
},
// Modern JavaScript target
compiler: {
removeConsole: isProduction,
},
};
export default nextConfig;