-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
91 lines (81 loc) · 2.12 KB
/
Copy pathnext.config.js
File metadata and controls
91 lines (81 loc) · 2.12 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
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
// Webpack configuration
webpack: (config, { isServer, webpack }) => {
// Handle node: protocol
config.plugins.push(
new webpack.NormalModuleReplacementPlugin(
/^node:/,
(resource) => {
resource.request = resource.request.replace(/^node:/, '');
}
)
);
// Polyfills and fallbacks for client-side
if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
buffer: require.resolve('buffer'),
process: require.resolve('process/browser'),
fs: false,
net: false,
tls: false,
child_process: false,
readline: false,
zlib: false,
http: false,
https: false,
os: false,
path: false,
util: false,
};
// Provide plugin for process and Buffer
config.plugins.push(
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process/browser',
})
);
}
// Handle .wasm files
config.module.rules.push({
test: /\.wasm$/,
type: 'asset/resource',
});
// Ignore specific modules that cause issues
config.resolve.alias = {
...config.resolve.alias,
'@avalabs/eerc-sdk': isServer ? false : '@avalabs/eerc-sdk',
};
return config;
},
// Transpile packages if needed
transpilePackages: ['@avalabs/eerc-sdk'],
// Headers for CORS
async headers() {
return [
{
source: '/eerc/:path*',
headers: [
{
key: 'Cross-Origin-Embedder-Policy',
value: 'require-corp',
},
{
key: 'Cross-Origin-Opener-Policy',
value: 'same-origin',
},
],
},
];
},
// Environment variables
env: {
NEXT_PUBLIC_AVAX_RPC: process.env.NEXT_PUBLIC_AVAX_RPC || 'https://api.avax.network/ext/bc/C/rpc',
},
};
module.exports = nextConfig;