-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathnext.config.js
More file actions
135 lines (129 loc) · 3.69 KB
/
next.config.js
File metadata and controls
135 lines (129 loc) · 3.69 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
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
transpilePackages: ['bignumber.js'],
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'assets.leapwallet.io',
},
{
protocol: 'https',
hostname: 'raw.githubusercontent.com',
},
{
protocol: 'https',
hostname: 'xdefi-static.s3.eu-west-1.amazonaws.com',
},
{
protocol: 'https',
hostname: 'i.stargaze-apis.com',
},
{
protocol: 'https',
hostname: 'ichef.bbci.co.uk',
},
],
},
async headers() {
return [
{
source: '/(.*)?',
headers: [
{
key: 'Referrer-Policy',
value: 'origin-when-cross-origin',
},
{
key: 'Cache-Control',
value: 'public, max-age=600, s-maxage=600, must-revalidate',
},
{
key: 'CDN-Cache-Control',
value: 'public, max-age=600, s-maxage=600, must-revalidate',
},
{
key: 'Expires',
value: '01',
},
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
],
},
]
},
async rewrites() {
return [
// Rewrite vault detail pages for bots to SSR endpoint
{
source: '/vaults/:vaultAddress/details',
destination: '/api/ssr/vaults/:vaultAddress',
has: [
{
type: 'header',
key: 'User-Agent',
value:
'(facebook|twitter|linkedin|telegram|discord|bot|crawl|spider|facebookexternalhit|Facebot|Twitterbot|TelegramBot|XtilesBot)',
},
],
},
// Also handle wallet-prefixed vault URLs for bots
{
source: '/wallets/:wallet/vaults/:vaultAddress/details',
destination: '/api/ssr/vaults/:vaultAddress',
has: [
{
type: 'header',
key: 'User-Agent',
value:
'(facebook|twitter|linkedin|telegram|discord|bot|crawl|spider|facebookexternalhit|Facebot|Twitterbot|TelegramBot|XtilesBot)',
},
],
},
// Rewrite frontend routes for non-bot user agents (excluding API routes)
{
source: '/((?!api|_next|favicon).*)',
destination: '/',
has: [
{
type: 'header',
key: 'User-Agent',
value:
'(^(?!facebook|twitter|linkedin|telegram|discord|bot|crawl|spider|facebookexternalhit|Facebot|Twitterbot|TelegramBot|XtilesBot).*$)',
},
],
},
]
},
webpack(config, { isServer }) {
config.module.rules.push({
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: ['@svgr/webpack'],
})
// Handle charting library - it's a UMD bundle that needs special treatment
// Use path.resolve instead of require.resolve to avoid issues when file doesn't exist yet
const path = require('path')
const fs = require('fs')
const chartingLibraryPath = path.resolve(__dirname, 'src/utils/charting_library/index.js')
// Only add alias if the file exists (it's created by install-charting-library script)
if (fs.existsSync(chartingLibraryPath)) {
config.resolve.alias = {
...config.resolve.alias,
'utils/charting_library': chartingLibraryPath,
}
}
// Fix for packages with only "exports" field (like @cosmjs)
// This ensures webpack can resolve them properly
config.resolve.extensionAlias = {
'.js': ['.js', '.ts', '.tsx'],
'.mjs': ['.mjs', '.mts'],
...config.resolve.extensionAlias,
}
return config
},
}
module.exports = nextConfig