forked from Invoice-Liquidity-Network/ILN-Frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
227 lines (224 loc) · 6.73 KB
/
Copy pathnext.config.ts
File metadata and controls
227 lines (224 loc) · 6.73 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
import type { NextConfig } from 'next';
import withPWA from 'next-pwa';
import { withSentryConfig } from '@sentry/nextjs';
const nextConfig: NextConfig & { allowedDevOrigins?: string[] } = {
reactStrictMode: true,
turbopack: {},
allowedDevOrigins: ['127.0.0.1', 'localhost'],
async headers() {
return [
{
source: '/:path*',
headers: [
{
key: 'Content-Security-Policy',
value: `
default-src 'self';
script-src 'self' 'unsafe-inline' 'unsafe-eval' *.vercel.app;
style-src 'self' 'unsafe-inline' https://fonts.googleapis.com;
font-src 'self' https://fonts.gstatic.com;
img-src 'self' data: https:;
media-src 'self';
connect-src 'self' https://stellar.expert https://horizon.stellar.org https://horizon-testnet.stellar.org https://rpc-futurenet.stellar.org https://soroban-rpc.stellar.org https://soroban-rpc.stellar.org https://*.supabase.co https://api.github.com;
frame-ancestors 'none';
object-src 'none';
base-uri 'self';
form-action 'self';
upgrade-insecure-requests;
`
.replace(/\s+/g, ' ')
.trim(),
},
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'X-Frame-Options',
value: 'DENY',
},
{
key: 'Referrer-Policy',
value: 'strict-origin-when-cross-origin',
},
{
key: 'Permissions-Policy',
value: 'geolocation=(), microphone=(), camera=()',
},
],
},
{
// RFC 9116 recommends serving security.txt as text/plain.
source: '/.well-known/security.txt',
headers: [
{
key: 'Content-Type',
value: 'text/plain; charset=utf-8',
},
],
},
];
},
async redirects() {
return [
{
source: '/dashboard/payer',
destination: '/payer',
permanent: true,
},
{
source: '/analytics/freelancer',
destination: '/analytics',
permanent: true,
},
{
source: '/analytics/leaderboard',
destination: '/leaderboard',
permanent: true,
},
{
// Excludes "batch", which is a real static route (app/invoices/batch)
// rather than an invoice id - without this, it would be redirected to
// /i/batch and crash trying to parse "batch" as an invoice id.
source: '/invoices/:id((?!batch$).*)',
destination: '/i/:id',
permanent: true,
},
];
},
async headers() {
return [
{
source: '/:path*',
headers: [
{
key: 'Content-Security-Policy',
value: [
"default-src 'self'",
"script-src 'self' 'unsafe-inline' 'unsafe-eval'",
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com",
"font-src 'self' https://fonts.gstatic.com data:",
"img-src 'self' data: https: blob:",
"connect-src 'self' https: wss:",
"object-src 'none'",
"base-uri 'self'",
"form-action 'self'",
"frame-ancestors 'none'",
'upgrade-insecure-requests',
].join('; '),
},
{
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=(), browsing-topics=()',
},
],
},
];
},
};
const pwaWrapped = withPWA({
dest: 'public',
register: true,
skipWaiting: true,
// Paired with skipWaiting so a newly-installed SW takes control of already
// open tabs immediately, rather than leaving them on a stale worker until
// the next full reload. See "Service Worker Security Model" in
// docs/architecture.md for the full threat-model writeup.
clientsClaim: true,
fallbacks: {
document: '/offline',
},
runtimeCaching: [
{
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'google-fonts',
cacheableResponse: { statuses: [0, 200] },
expiration: {
maxEntries: 4,
maxAgeSeconds: 365 * 24 * 60 * 60, // 365 days
},
},
},
{
urlPattern: /^https:\/\/fonts\.gstatic\.com\/.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'google-fonts-static',
cacheableResponse: { statuses: [0, 200] },
expiration: {
maxEntries: 4,
maxAgeSeconds: 365 * 24 * 60 * 60, // 365 days
},
},
},
{
urlPattern: /\.(?:js|css|woff|woff2|ttf|eot)$/i,
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'static-assets',
cacheableResponse: { statuses: [0, 200] },
expiration: {
maxEntries: 64,
maxAgeSeconds: 24 * 60 * 60, // 24 hours
},
},
},
{
urlPattern: /\/api\/.*$/i,
handler: 'NetworkFirst',
options: {
cacheName: 'api-cache',
// Only cache clean same-origin (0 = opaque no-cors, kept for parity
// with other entries) and 200 responses - error bodies and redirects
// must never be persisted as if they were valid API responses.
cacheableResponse: { statuses: [0, 200] },
expiration: {
maxEntries: 16,
maxAgeSeconds: 24 * 60 * 60, // 24 hours
},
networkTimeoutSeconds: 10,
},
},
{
urlPattern: ({ request }: any) => request.destination === 'document',
handler: 'NetworkFirst',
options: {
cacheName: 'pages',
cacheableResponse: { statuses: [0, 200] },
expiration: {
maxEntries: 32,
maxAgeSeconds: 24 * 60 * 60, // 24 hours
},
networkTimeoutSeconds: 10,
},
},
],
})(nextConfig);
// Wrap with Sentry to enable source map upload at build time.
// Source maps are deleted from the Vercel CDN after upload (hideSourceMaps: true)
// so they are not publicly accessible. See docs/sentry-integration.md.
export default withSentryConfig(pwaWrapped, {
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
silent: !process.env.CI,
hideSourceMaps: true,
disableLogger: true,
});