-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathnext.config.mjs
More file actions
153 lines (148 loc) · 4.96 KB
/
next.config.mjs
File metadata and controls
153 lines (148 loc) · 4.96 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
import { withSentryConfig } from '@sentry/nextjs';
import packageInfo from './package.json' with { type: 'json' };
const webFunctionalities = [
'accelerometer=()',
'attribution-reporting=()',
'autoplay=()',
'bluetooth=()',
'browsing-topics=()',
'camera=()',
'compute-pressure=()',
'cross-origin-isolated=()',
'display-capture=()',
'encrypted-media=()',
'fullscreen=()',
'gamepad=()',
'geolocation=()',
'gyroscope=()',
'hid=()',
'idle-detection=()',
'local-fonts=()',
'magnetometer=()',
'microphone=()',
'midi=()',
'otp-credentials=()',
'payment=()',
'picture-in-picture=()',
'publickey-credentials-create=()',
'publickey-credentials-get=()',
'screen-wake-lock=()',
'serial=()',
'storage-access=()',
'usb=()',
'web-share=()',
'window-management=()',
'xr-spatial-tracking=()',
];
const isPreview = process.env.NEXT_PUBLIC_ENV === 'preview';
const isDevelopment = process.env.NEXT_PUBLIC_ENV === 'development';
const disableSourcemaps = isPreview || isDevelopment;
const sentryConfig = {
// Aragon organisation on Sentry
org: process.env.SENTRY_ORG ?? process.env.NEXT_PUBLIC_SENTRY_ORG,
// Sentry project
project:
process.env.SENTRY_PROJECT ?? process.env.NEXT_PUBLIC_SENTRY_PROJECT,
// Auth token needed for uploading source maps
authToken:
process.env.SENTRY_AUTH_TOKEN ??
process.env.NEXT_SECRET_SENTRY_AUTH_TOKEN,
// Make sure to upload all files and source maps
widenClientFileUpload: true,
// Use tunneling to forward events to Sentry and circumvent ad blockers
tunnelRoute: '/api/monitoring',
// Tree-shake Sentry debug statements to save bundle size (replaces deprecated disableLogger)
bundleSizeOptimizations: {
excludeDebugStatements: true,
excludeReplayWorker: true,
},
// Release version for Sentry
release: { name: packageInfo.version },
// Delete sourcemaps from NextJs build after upload
// Disable source map upload for preview environments
sourcemaps: disableSourcemaps
? { disable: true }
: { deleteSourcemapsAfterUpload: true },
// Disable sending data to Sentry
telemetry: false,
// Mark first-party bundles for thirdPartyErrorFilterIntegration
_experimental: {
turbopackApplicationKey: 'aragon-app',
},
};
/** @type {import('next').NextConfig} */
const nextConfig = {
async redirects() {
return [
{
source: '/dao/:network/:addressOrEns',
destination: '/dao/:network/:addressOrEns/dashboard',
permanent: true,
},
];
},
async headers() {
return [
// Security headers for all paths
{
source: '/:path*',
headers: [
// Do not allow usage of application inside iframes
{ key: 'X-Frame-Options', value: 'DENY' },
// Enforce HTTPS access
{
key: 'Strict-Transport-Security',
value: 'max-age=63072000; includeSubDomains; preload',
},
// Explicitly disable all web functionalities
{
key: 'Permissions-Policy',
value: webFunctionalities.join(', '),
},
// Prevents the browser from guessing the content type when related header is not set
{ key: 'X-Content-Type-Options', value: 'nosniff' },
// Allow browsers to proactively perform domain name resolution on extenal resources (links, CSS, ..)
{ key: 'X-DNS-Prefetch-Control', value: 'on' },
],
},
// CORS headers for api routes
{
source: '/api/:path*',
headers: [
{
key: 'Access-Control-Allow-Origin',
value: process.env.NEXT_PUBLIC_API_ALLOWED_DOMAIN,
},
{ key: 'Access-Control-Allow-Methods', value: 'POST' },
{
key: 'Access-Control-Allow-Headers',
value: 'Content-Type',
},
],
},
];
},
images: {
remotePatterns: [
{
protocol: 'https',
hostname: '**',
port: '',
},
],
},
env: {
version: packageInfo.version,
},
serverExternalPackages: ['pino-pretty', 'lokijs', 'encoding'],
reactCompiler: false,
turbopack: {
resolveAlias: {
'@react-native-async-storage/async-storage': {
browser: './src/empty.ts',
},
'react-native': { browser: './src/empty.ts' },
},
},
};
export default withSentryConfig(nextConfig, sentryConfig);