-
Notifications
You must be signed in to change notification settings - Fork 21
/
next.config.js
90 lines (85 loc) · 2.41 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
const {createVanillaExtractPlugin} = require('@vanilla-extract/next-plugin');
const withVanillaExtract = createVanillaExtractPlugin();
const {PHASE_DEVELOPMENT_SERVER} = require('next/constants')
/** @type {import('next').NextConfig} */
const mainNetEndpoint = process.env.NEXT_PUBLIC_RPC_NODE;
/** We should put all environment dependent variables into this file. However, Prod RPC NODE should still reside in
* .env file for security reason. API Keys and secrets should also reside in .env file
* "yarn dev" is dev build so by default should use the settings related to dev-net
* "yarn build/yarn start" is prod build so by default should use settings related to Mainnet
* */
const ContentSecurityPolicy = `
default-src 'self';
script-src 'self';
child-src honey.finance;
style-src 'self' honey.finance;
font-src 'self';
frame-ancestors 'none';
`
// Add security headers configuration
const securityHeaders = [
// Not supported on newest browser versions
{
key: 'X-Frame-Options',
value: 'DENY'
},
{
key: 'Content-Security-Policy',
value: ContentSecurityPolicy.replace(/\s{2,}/g, ' ').trim()
}
]
module.exports = (phase, {defaultConfig}) => {
if (phase === PHASE_DEVELOPMENT_SERVER) {
const env = {
NETWORK: 'devnet',
NETWORK_CONFIGURATION: undefined,
async headers() {
return [
{
// Apply these headers to all routes in your application.
source: '/(.*)',
headers: securityHeaders,
},
]
}
}
const devNextConfig = {
reactStrictMode: true,
env: env,
domains:[
"quote-api.jup.ag",
"www.google-analytics.com"
]
};
return withVanillaExtract(devNextConfig)
} else {
const env = {
NETWORK: "mainnet-beta",
NETWORK_CONFIGURATION: {
'mainnet-beta': {
name: 'mainnet-beta',
endpoint: mainNetEndpoint,
confirmTransactionInitialTimeout: 180000,
}
},
async headers() {
return [
{
// Apply these headers to all routes in your application.
source: '/(.*)',
headers: securityHeaders,
},
]
}
}
const ProdNextConfig = {
reactStrictMode: true,
env: env,
domains:[
"quote-api.jup.ag",
"www.google-analytics.com"
]
};
return withVanillaExtract(ProdNextConfig)
}
}