Repository navigation
Expand file tree
/
Copy pathnext.config.mjs
More file actions
98 lines (93 loc) · 2.76 KB
/
Copy pathnext.config.mjs
File metadata and controls
98 lines (93 loc) · 2.76 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
import { fileURLToPath } from 'url';
import path from 'path';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
// Ensure these external packages are transpiled (ESM/CJS interop)
transpilePackages: [
'@rainbow-me/rainbowkit',
],
// Disable cache for dynamic pages
experimental: {
staleTimes: {
dynamic: 0,
static: 0,
},
},
// Configure headers to prevent browser caching
async headers() {
const isDev = process.env.NODE_ENV !== 'production';
const csp = [
"default-src 'self'",
`script-src 'self' 'unsafe-inline'${isDev ? " 'unsafe-eval'" : ''}`,
"style-src 'self' 'unsafe-inline'",
"img-src 'self' data: https:",
"font-src 'self' data:",
"connect-src 'self' https: wss:",
"frame-ancestors 'self'",
"form-action 'self'",
"base-uri 'self'",
"object-src 'none'",
!isDev ? 'upgrade-insecure-requests' : null,
].filter(Boolean).join('; ');
return [
{
source: '/(.*)',
headers: [
// Removed duplicate CSP header; middleware.js now governs CSP
{ key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
{ key: 'X-Content-Type-Options', value: 'nosniff' },
{ key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' },
],
},
// Prevent stale HTML from referencing old build IDs after redeploys
{
source: '/login',
headers: [
{ key: 'Cache-Control', value: 'no-store, no-cache, must-revalidate, proxy-revalidate' },
],
},
{
source: '/dashboard',
headers: [
{ key: 'Cache-Control', value: 'no-store, no-cache, must-revalidate, proxy-revalidate' },
],
},
{
source: '/profile',
headers: [
{ key: 'Cache-Control', value: 'no-store, no-cache, must-revalidate, proxy-revalidate' },
],
},
{
source: '/token/:path*',
headers: [
{ key: 'Cache-Control', value: 'no-store, no-cache, must-revalidate, proxy-revalidate' },
],
},
];
},
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'coin-images.coingecko.com',
},
{
protocol: 'https',
hostname: 'assets.coingecko.com',
},
{
protocol: 'https',
hostname: 's2.coinmarketcap.com', // Added for CoinMarketCap
},
],
},
webpack: (config) => {
config.resolve.alias['@'] = path.resolve(__dirname, '.');
// Removed alias override for '@vanilla-extract/sprinkles/createUtils' to avoid circular import issues
return config;
},
};
export default nextConfig;