-
Notifications
You must be signed in to change notification settings - Fork 50
/
next.config.js
113 lines (97 loc) · 2.71 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
const path = require('path');
require('dotenv').config({ path: './.env' });
const securityHeaders = [
// Adds x-xss-protection
{
key: 'X-XSS-Protection',
value: '1; mode=block'
},
// adds x-frame-options
// remove for safe app to load
// {
// key: 'X-Frame-Options',
// value: 'SAMEORIGIN'
// },
// adds frame-ancestors which supercedes X-Frame-Options
// https://nextjs.org/docs/advanced-features/security-headers#x-frame-options
{
key: 'frame-ancestors',
value: 'https://app.safe.global'
},
// adds x-content-type
{
key: 'X-Content-Type-Options',
value: 'nosniff'
},
// required for safe app to load
{
key: 'Access-Control-Allow-Origin',
value: '*'
},
{
key: 'Access-Control-Allow-Methods',
value: 'GET'
},
{
key: 'Access-Control-Allow-Headers',
value: 'X-Requested-With, content-type, Authorization'
}
];
//// Main Next.js config
const moduleExports = {
// everything in here gets exposed to the frontend.
// prefer NEXT_PUBLIC_* instead, which makes this behavior more explicit
env: {
INFURA_KEY: process.env.INFURA_KEY || '84842078b09946638c03157f83405213', // ethers default infura key
ALCHEMY_KEY: process.env.ALCHEMY_KEY || '_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC', // ethers default alchemy key
POCKET_KEY: process.env.POCKET_KEY,
ETHERSCAN_KEY: process.env.ETHERSCAN_KEY,
GITHUB_TOKEN: process.env.GITHUB_TOKEN
},
// Opt-in SWC minification (next 12.0.2)
// swcMinify: true, // fatal runtime error: failed to initiate panic, error 5
webpack: (config, { isServer }) => {
if (!isServer) {
// Fixes npm packages that depend on `fs` module
// https://github.com/vercel/next.js/issues/7755#issuecomment-508633125
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
dns: false,
net: false,
tls: false
};
}
config.resolve.alias['lib'] = path.join(__dirname, 'lib');
config.resolve.alias['components'] = path.join(__dirname, 'components');
config.resolve.alias['stores'] = path.join(__dirname, 'stores');
return config;
},
async rewrites() {
return [
{
source: '/delegates/:address',
destination: '/address/:address'
},
{
source: '/api/polling/all-polls',
destination: '/api/polling/v1/all-polls'
},
{
source: '/api/delegates',
destination: '/api/delegates/v1'
}
];
},
async headers() {
return [
{
// Apply these headers to all routes in your application.
source: '/:path*',
headers: securityHeaders
}
];
},
staticPageGenerationTimeout: 120
};
module.exports = moduleExports;