-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
115 lines (113 loc) · 3.67 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
114
115
const { PHASE_DEVELOPMENT_SERVER } = require('next/constants');
const nextTranslate = require('next-translate');
module.exports = (phase, { defaultConfig }) => {
const dms = process.env.DMS;
const cms = process.env.CMS;
const cmsKey = process.env.CMS_KEY;
const MAIL_PORT = process.env.EMAIL_PORT;
const MAIL_SERVER = process.env.MAIL_SERVER;
const MAIL_PASSWORD = process.env.MAIL_PASSWORD;
const CONTACT_EMAIL = process.env.CONTACT_EMAIL;
const MAIL_ACCOUNT = process.env.MAIL_ACCOUNT;
const REQUEST_DATA_EMAIL = process.env.REQUEST_DATA_EMAIL;
if (phase === PHASE_DEVELOPMENT_SERVER) {
if (dms) {
console.log('\nYou are running the app in dev mode 🌀');
console.log(
'Did you know that you can use mocked CKAN API? Just unset your `DMS` env var.'
);
console.log('Happy coding ☀️\n');
} else {
const mocks = require('./mocks');
mocks.initMocks();
console.log(
'\nYou have not defined any DMS API so we are activating the mocks ⚠️'
);
console.log(
'If you wish to run against your CKAN API, you can set `DMS` env var.'
);
console.log(
'For example, to run against demo ckan site: `DMS=https://demo.ckan.org`\n'
);
}
return nextTranslate({
publicRuntimeConfig: {
DMS: dms ? dms.replace(/\/?$/, '') : 'http://mock.ckan',
CMS: cms ? cms.replace(/\/?$/, '') : 'oddk.home.blog',
CMS_KEY: cmsKey,
},
serverRuntimeConfig: {
DMS: dms ? dms.replace(/\/?$/, '') : 'http://mock.ckan',
CMS: cms ? cms.replace(/\/?$/, '') : 'oddk.home.blog',
CMS_KEY: cmsKey,
MAIL_PORT,
MAIL_PASSWORD,
MAIL_SERVER,
CONTACT_EMAIL,
MAIL_ACCOUNT,
REQUEST_DATA_EMAIL,
},
async rewrites() {
return {
afterFiles: [
{
source:
'/dataset/:datasetId/resource/:resourceId/download/:file',
destination: `${
dms ? dms.replace(/\/?$/, '') : 'https://demo.dev.datopian.com'
}/dataset/:datasetId/resource/:resourceId/download/:file`,
},
],
};
},
images: {
domains: [
dms.replace(/\/?$/, '').replace(/https:\/\//, ''),
cms.replace(/\/?$/, '').replace(/https:\/\//, ''),
],
dangerouslyAllowSVG: true,
contentSecurityPolicy:
"default-src 'self'; script-src 'none'; sandbox;",
},
});
}
return nextTranslate({
publicRuntimeConfig: {
DMS: dms ? dms.replace(/\/?$/, '') : 'https://demo.dev.datopian.com',
CMS: cms ? cms.replace(/\/?$/, '') : 'oddk.home.blog',
CMS_KEY: cmsKey,
},
serverRuntimeConfig: {
DMS: dms ? dms.replace(/\/?$/, '') : 'https://demo.dev.datopian.com',
CMS: cms ? cms.replace(/\/?$/, '') : 'oddk.home.blog',
CMS_KEY: cmsKey,
MAIL_PORT,
MAIL_PASSWORD,
MAIL_SERVER,
CONTACT_EMAIL,
MAIL_ACCOUNT,
REQUEST_DATA_EMAIL,
},
async rewrites() {
return {
afterFiles: [
{
source: '/dataset/:datasetId/resource/:resourceId/download/:file',
destination: `${
dms ? dms.replace(/\/?$/, '') : 'https://demo.dev.datopian.com'
}/dataset/:datasetId/resource/:resourceId/download/:file`,
},
],
};
},
output: 'standalone',
images: {
domains: [
dms.replace(/\/?$/, '').replace(/https:\/\//, ''),
cms.replace(/\/?$/, '').replace(/https:\/\//, ''),
],
dangerouslyAllowSVG: true,
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
},
});
};