Repository navigation
Expand file tree
/
Copy pathnext.config.mjs
More file actions
158 lines (146 loc) · 4.46 KB
/
Copy pathnext.config.mjs
File metadata and controls
158 lines (146 loc) · 4.46 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
import withPWAInit from "@ducanh2912/next-pwa";
const withPWA = withPWAInit({
dest: "public",
// disable when developing or if an explicit flag is set. this is useful for
// build hosts that lack outgoing network connectivity (avoid ETIMEDOUT
// retries during the service-worker generation phase).
disable: process.env.NODE_ENV === "development" || process.env.DISABLE_PWA === "true",
register: true,
skipWaiting: true,
cacheOnFrontEndNav: false, // Disabled to prevent buggy reloads
aggressiveFrontEndNavCaching: false, // Disabled for stability
reloadOnOnline: false, // Prevent reloads on network changes
swMinify: true,
// The app keeps only what the offline page needs. Pictures (course art, badges,
// photos: 5.6 MB) load when a page shows them; precaching them made the first
// visit download 9 MB before notifications could even turn on.
publicExcludes: [
"!noprecache/**/*",
"!badges/**/*",
"!curriculum/**/*",
"!images/**/*",
"!screenshots/**/*",
"!*.png",
"!*.jpg",
],
workboxOptions: {
disableDevLogs: true,
maximumFileSizeToCacheInBytes: 5000000,
importScripts: ["/push-sw.js"],
},
fallbacks: {
document: "/offline",
},
});
/** @type {import('next').NextConfig} */
const nextConfig = {
// Don't announce the framework and version in every response.
poweredByHeader: false,
// TypeScript settings
typescript: {
ignoreBuildErrors: true,
},
// Server configuration for large file uploads
experimental: {
serverActions: {
bodySizeLimit: '500mb', // Increased to 500MB for video uploads
},
optimizeCss: true,
agentUpgrade: false,
// Removed forceSwcTransforms - not supported by Turbopack
},
output: 'standalone',
// Share images (lib/og.tsx) read fonts and brand marks from assets/ at runtime;
// make sure the standalone build ships them.
outputFileTracingIncludes: {
'/**/*': ['./assets/fonts/**/*', './assets/brand/**/*'],
},
outputFileTracingRoot: process.cwd(),
// Images configuration
images: {
// Allow local images in development, optimize in production
unoptimized: process.env.NODE_ENV === 'development',
remotePatterns: [
{
protocol: 'https',
hostname: 'picsum.photos',
port: '',
pathname: '/**',
},
{
protocol: 'https',
hostname: 'cdn.sanity.io',
port: '',
pathname: '/**',
},
{
protocol: 'https',
hostname: 'tmvipinvvhgklmqwvows.supabase.co',
port: '',
pathname: '/storage/v1/object/public/**',
},
{
protocol: 'https',
hostname: 'tmvipinvvhgklmqwvows.supabase.co',
port: '',
pathname: '/storage/v1/object/sign/**',
},
{
protocol: 'https',
hostname: 'lh3.googleusercontent.com',
port: '',
pathname: '/**',
},
{
protocol: 'https',
hostname: 'api.dicebear.com',
port: '',
pathname: '/**',
},
{
protocol: 'https',
hostname: 'i.pravatar.cc',
port: '',
pathname: '/**',
},
{
protocol: 'https',
hostname: 'i.ibb.co',
port: '',
pathname: '/**',
},
{
protocol: 'https',
hostname: 'avatars.githubusercontent.com',
port: '',
pathname: '/**',
},
// Uploads (Cloudflare R2): development address and the custom domain.
{ protocol: 'https', hostname: '*.r2.dev', pathname: '/**' },
{ protocol: 'https', hostname: 'files.zigexconnect.com', pathname: '/**' },
],
},
// CORS and security headers with increased payload limits
async headers() {
return [
{
source: '/api/:path*',
headers: [
{ key: 'Access-Control-Allow-Credentials', value: 'true' },
{ key: 'Access-Control-Allow-Origin', value: process.env.FRONTEND_URL || 'http://localhost:3000' },
{ key: 'Access-Control-Allow-Methods', value: 'GET,PUT,POST,DELETE,PATCH,OPTIONS' },
{ key: 'Access-Control-Allow-Headers', value: 'Content-Type, Authorization, X-Requested-With' },
// Increase max upload size headers
{ key: 'X-Max-Body-Size', value: '500mb' },
]
}
]
},
// Turbopack compatibility (Next.js 16 defaults to Turbopack)
turbopack: {},
// Console removal in production
compiler: {
// removeConsole: process.env.NODE_ENV === 'production',
},
};
export default withPWA(nextConfig);