-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnext.config.js
More file actions
71 lines (64 loc) · 1.89 KB
/
next.config.js
File metadata and controls
71 lines (64 loc) · 1.89 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
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
// Next.js 16+ uses Turbopack by default
// Empty config acknowledges we're okay with Turbopack (it handles workers natively)
turbopack: {},
// Exclude public assets from serverless function bundling
// Without this, Vercel bundles all public/ files into API routes that use fs
outputFileTracingExcludes: {
'/api/*': ['./public/**/*'],
},
// Security headers required for SharedArrayBuffer (WASM threading)
// Safari requires these headers for SharedArrayBuffer to be available
// Without them, WASM modules like recast-navigation will fail to initialize
async headers() {
return [
{
// Apply to all routes
source: '/:path*',
headers: [
{
key: 'Cross-Origin-Opener-Policy',
value: 'same-origin',
},
{
key: 'Cross-Origin-Embedder-Policy',
value: 'credentialless',
},
],
},
{
// Service worker must never be cached by the browser
source: '/sw.js',
headers: [
{
key: 'Cache-Control',
value: 'no-cache, no-store, must-revalidate',
},
{
key: 'Content-Type',
value: 'application/javascript; charset=utf-8',
},
],
},
];
},
webpack: (config, { isServer }) => {
// Legacy worker-loader support (only applies when NOT using Turbopack)
// Turbopack handles workers natively via new Worker(new URL(...), { type: 'module' })
config.module.rules.push({
test: /\.worker\.(js|ts)$/,
use: { loader: 'worker-loader' },
});
// Fix for three.js
if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
};
}
return config;
},
};
module.exports = nextConfig;