-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnext.config.js
139 lines (129 loc) · 3.64 KB
/
next.config.js
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
/** @type {import('next').NextConfig} */
// Suppress Node.js warnings including punycode deprecation
const originalEmit = process.emit;
process.emit = function (name, data, ...args) {
if (
name === `warning` &&
typeof data === "object" &&
data.name === "DeprecationWarning" &&
data.message.includes("punycode")
) {
return false;
}
return originalEmit.apply(process, [name, data, ...args]);
};
const nextConfig = {
// Core configuration
reactStrictMode: true,
poweredByHeader: false,
compress: true,
swcMinify: true,
productionBrowserSourceMaps: false,
// Environment Variables Configuration
env: {
// Only expose necessary environment variables to the client
API_URL: process.env.API_URL || '/api',
APP_URL: process.env.APP_URL || 'http://localhost:3000',
DEFAULT_CHAIN: process.env.DEFAULT_CHAIN || 'aptos',
SIMPLEHASH_API_KEY: process.env.SIMPLEHASH_API_KEY,
// Expose wallet addresses for client-side configuration
...Object.keys(process.env).reduce((acc, key) => {
if (key.match(/^(SOLANA|APTOS|SUI)_WALLET_/)) {
acc[key] = process.env[key]
}
return acc
}, {}),
},
// Image optimization
images: {
unoptimized: false, // Enable image optimization
domains: ['cdn.simplehash.com'], // Add domains you'll use for images
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048],
imageSizes: [16, 32, 48, 64, 96, 128, 256],
formats: ['image/webp'],
minimumCacheTTL: 60,
},
// Webpack optimizations
webpack: (config, { dev, isServer }) => {
// Production optimizations
if (!dev) {
// Enable tree shaking
config.optimization = {
...config.optimization,
usedExports: true,
sideEffects: true,
minimize: true,
moduleIds: 'deterministic',
chunkIds: 'deterministic',
mangleExports: true,
};
}
// Handle ESM modules
config.resolve.alias = {
...config.resolve.alias,
"decimal.js-light": require.resolve("decimal.js-light"),
};
return config;
},
// Headers for security and performance
async headers() {
return [
{
source: "/:path*",
headers: [
{
key: "X-DNS-Prefetch-Control",
value: "on",
},
{
key: "Strict-Transport-Security",
value: "max-age=31536000; includeSubDomains; preload",
},
{
key: "X-Content-Type-Options",
value: "nosniff",
},
{
key: "X-Frame-Options",
value: "DENY",
},
{
key: "X-XSS-Protection",
value: "1; mode=block",
},
{
key: "Referrer-Policy",
value: "strict-origin-when-cross-origin",
},
{
key: "Permissions-Policy",
value: "camera=(), microphone=(), geolocation=()",
},
],
},
{
source: "/api/:path*",
headers: [
{ key: "Access-Control-Allow-Credentials", value: "true" },
{ key: "Access-Control-Allow-Origin", value: "*" },
{
key: "Access-Control-Allow-Methods",
value: "GET,POST,OPTIONS,PUT,DELETE",
},
{
key: "Access-Control-Allow-Headers",
value:
"X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, Authorization",
},
],
},
];
},
// Stable features only
experimental: {
serverActions: {
bodySizeLimit: "2mb",
},
},
};
module.exports = nextConfig;