-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.js
More file actions
236 lines (210 loc) · 8.88 KB
/
next.config.js
File metadata and controls
236 lines (210 loc) · 8.88 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
/** @type {import('next').NextConfig} */
console.log('🔍 Next.js Configuration - ALWAYS USE FULL ERROR MESSAGES:');
console.log(' NODE_ENV:', process.env.NODE_ENV);
console.log(' VERCEL_ENV:', process.env.VERCEL_ENV);
console.log(' Full errors enabled: ALWAYS (development, preview, and production)');
const nextConfig = {
reactStrictMode: process.env.NODE_ENV === 'development', // Disable in production to prevent hydration issues
// Force full error messages in ALL environments (dev, preview, production)
env: {
// Force React to always use development error messages
FORCE_FULL_ERRORS: 'true',
REACT_APP_FULL_ERRORS: 'true',
VERCEL_ENV: process.env.VERCEL_ENV || 'development',
NEXT_PUBLIC_VERCEL_ENV: process.env.VERCEL_ENV || 'development',
},
// Maximum error visibility settings
onDemandEntries: {
maxInactiveAge: 25 * 1000,
pagesBufferLength: 2,
},
// Disable source maps in production for security (use error tracking services instead)
productionBrowserSourceMaps: false,
// Minimal webpack logging for development
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
// FORCE FULL ERROR MESSAGES: Configure React for better error messages
console.log('🔧 Webpack: Configuring enhanced error messages');
// Use DefinePlugin to improve error messages without breaking the build
config.plugins.push(
new webpack.DefinePlugin({
// Keep React in production mode but enhance our error logging
'__REACT_ERROR_OVERLAY__': JSON.stringify(true),
'process.env.REACT_APP_FULL_ERRORS': JSON.stringify('true'),
})
);
// Reduce webpack output for cleaner development
if (dev) {
// Ignore directories that shouldn't trigger Fast Refresh
config.watchOptions = {
...config.watchOptions,
ignored: [
'**/node_modules/**',
'**/.next/**',
'**/.git/**',
'**/logs/**',
'**/scripts/**',
'**/docs/**',
'**/*.tsbuildinfo',
'**/.claude/**',
'**/coverage/**',
'**/dist/**',
'**/.turbo/**',
],
// Debounce file change events to reduce rebuilds
aggregateTimeout: 300,
// Use polling only if native watchers fail (set to false for native watching)
poll: false,
};
config.stats = {
errors: true,
warnings: true,
timings: false,
assets: false,
chunks: false,
modules: false,
reasons: false,
source: false,
publicPath: false,
builtAt: false,
version: false,
hash: false,
chunkModules: false,
chunkOrigins: false,
depth: false,
env: false,
orphanModules: false,
providedExports: false,
usedExports: false,
optimizationBailout: false,
};
config.infrastructureLogging = {
level: 'warn',
debug: false,
};
}
// Force error emission (updated for Next.js 15.4.1)
config.optimization = {
...config.optimization,
emitOnErrors: true,
};
// Add error handling plugin
config.plugins.push(
new webpack.DefinePlugin({
'process.env.ENABLE_VERBOSE_LOGGING': JSON.stringify('true'),
'process.env.USE_DEV_AUTH': JSON.stringify(process.env.USE_DEV_AUTH || 'false'),
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
})
);
return config;
},
// Enable TypeScript error checking in development
typescript: {
ignoreBuildErrors: true, // Temporarily ignore for Vercel build
},
// Experimental features for better error reporting
experimental: {
forceSwcTransforms: false,
// Enable server source maps so prerender errors show actual file/line
// instead of minified chunk positions (e.g. "33313.js:43:65987")
serverSourceMaps: true,
// Disable optimizations that can cause hydration issues in production
...(process.env.NODE_ENV === 'development' && {
optimizePackageImports: ['slate', 'slate-react']
}),
},
// External packages for server components
// These packages should not be bundled and will use node_modules at runtime
// The firebase-admin dependency chain requires jwks-rsa which requires jose
serverExternalPackages: [
'firebase-admin',
'@google-cloud/firestore',
'@google-cloud/storage',
'jwks-rsa',
'jose',
],
// Explicitly include jose in serverless function traces
// This fixes the "Cannot find package 'jose'" error on Vercel when using bun lockfile
// bun creates a .bun folder symlink structure that Vercel's runtime can't resolve
outputFileTracingIncludes: {
'/api/**/*': ['./node_modules/jose/**/*', './node_modules/jwks-rsa/**/*'],
},
// Logging configuration
logging: {
fetches: {
fullUrl: false, // Reduce noise from fetch logging
hmrRefreshes: false, // Disable spammy Fast Refresh logs
},
},
// Reduce server-side request logging
async rewrites() {
return [];
},
// Security headers for Stripe Connect embedded components
async headers() {
return [
{
source: '/(.*)',
headers: [
// SECURITY: Strict-Transport-Security (HSTS)
// Forces HTTPS for 1 year, including subdomains
{
key: 'Strict-Transport-Security',
value: 'max-age=31536000; includeSubDomains; preload'
},
// SECURITY: Prevent clickjacking attacks
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN'
},
// SECURITY: Prevent MIME type sniffing
{
key: 'X-Content-Type-Options',
value: 'nosniff'
},
// SECURITY: Control referrer information
{
key: 'Referrer-Policy',
value: 'strict-origin-when-cross-origin'
},
// SECURITY: Permissions Policy (formerly Feature-Policy)
{
key: 'Permissions-Policy',
value: 'camera=(), microphone=(), geolocation=(self), interest-cohort=()'
},
// SECURITY: XSS Protection (legacy browsers)
{
key: 'X-XSS-Protection',
value: '1; mode=block'
},
{
key: 'Content-Security-Policy',
value: [
"default-src 'self'",
"script-src 'self' 'unsafe-inline' 'unsafe-eval' https://js.stripe.com https://connect-js.stripe.com https://*.stripe.com https://cdn.logrocket.io https://cdn.lr-ingest.io https://cdn.lr-in.com https://cdn.lr-in-prod.com https://cdn.lr-ingest.com https://cdn.ingest-lr.com https://cdn.lgrckt-in.com https://cdn.logr-in.com https://www.googletagmanager.com https://*.googleapis.com https://apis.google.com https://va.vercel-scripts.com https://vercel.live https://challenges.cloudflare.com",
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://connect-js.stripe.com https://*.stripe.com",
"font-src 'self' https://fonts.gstatic.com",
"img-src 'self' data: https: https://*.stripe.com https://*.tile.openstreetmap.org https://*.basemaps.cartocdn.com https://cdnjs.cloudflare.com",
"connect-src 'self' https://api.stripe.com https://connect-js.stripe.com https://*.stripe.com wss://*.stripe.com https://*.googleapis.com https://apis.google.com https://firebase.googleapis.com https://firestore.googleapis.com https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel https://firebaseinstallations.googleapis.com https://securetoken.googleapis.com https://identitytoolkit.googleapis.com wss://*.firebaseio.com https://*.firebaseio.com https://www.googletagmanager.com https://www.google-analytics.com https://analytics.google.com https://*.logrocket.io https://*.lr-ingest.io https://*.logrocket.com https://*.lr-in.com https://*.lr-in-prod.com https://*.lr-ingest.com https://*.ingest-lr.com https://cdn.lgrckt-in.com https://*.lgrckt-in.com https://va.vercel-scripts.com https://*.vercel-scripts.com wss://api.wewrite.app https://api.wewrite.app https://cdn.lordicon.com https://challenges.cloudflare.com",
"report-uri /api/csp-violations",
"frame-src 'self' https://js.stripe.com https://connect-js.stripe.com https://*.stripe.com https://*.firebaseapp.com https://wewrite-ccd82.firebaseapp.com https://challenges.cloudflare.com",
"worker-src 'self' blob:",
"child-src 'self' blob:",
"object-src 'none'",
"base-uri 'self'"
].join('; ')
}
]
}
];
},
// Custom error pages (rewrites defined above)
// Enable all development features
devIndicators: {
position: 'bottom-right',
},
// Maximum error details in production
generateEtags: false,
poweredByHeader: false,
compress: true, // Enable gzip compression for ~70% smaller payloads
}
module.exports = nextConfig