-
Notifications
You must be signed in to change notification settings - Fork 2
/
next.config.js
219 lines (215 loc) · 7.93 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
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
const { version } = require('./package.json');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const cspHeader = `default-src 'self' ;
img-src 'self'
*
data:
;
script-src 'self' 'unsafe-inline' 'unsafe-eval'
blob:
https://orkg.org
https://*.orkg.org
https://support.tib.eu
https://tibhannover.gitlab.io
https://www.gstatic.com
https://platform.twitter.com
https://cdn.syndication.twimg.com
https://cdnjs.cloudflare.com
https://app.chatwoot.com
;
style-src 'self' 'unsafe-inline'
https://orkg.org
https://*.orkg.org
https://maxcdn.bootstrapcdn.com
https://www.gstatic.com
https://platform.twitter.com
https://*.twimg.com
https://unpkg.com/[email protected]/dist/leaflet.css
;
font-src 'self'
data:
https://orkg.org
https://*.orkg.org
https://maxcdn.bootstrapcdn.com
https://cdnjs.cloudflare.com
;
frame-src 'self'
localhost:*
https://orkg.org
https://*.orkg.org
https://av.tib.eu
http://av.tib.eu
https://platform.twitter.com
https://syndication.twitter.com
https://www.youtube.com
https://time.graphics
https://app.chatwoot.com
https://support.tib.eu
;
frame-ancestors 'self' https://accounts.orkg.org;
connect-src 'self'
blob:
localhost:*
127.0.0.1:*
https://orkg.org
https://*.orkg.org
https://support.tib.eu
https://api.altmetric.com
https://doi.org
https://data.crosscite.org
https://secure.geonames.org
https://service.tib.eu
https://pub.orcid.org
https://api.semanticscholar.org
https://api.datacite.org
https://api.crossref.org
https://app.chatwoot.com
https://opencitations.net
https://*.wikidata.org
https://*.wikipedia.org/api/
https://dbpedia.org/sparql
https://api.unpaywall.org
https://raw.githubusercontent.com
https://fonts.gstatic.com
https://mastodon.social
;`;
/** @type {import('next').NextConfig} */
const nextConfig = {
async headers() {
return [
{
source: '/(.*)',
headers: [
{
key: 'Content-Security-Policy',
value: cspHeader.replace(/\n/g, ''),
},
],
},
];
},
swcMinify: true, // different minification, speeds up compiling in dev mode
reactStrictMode: false, // otherwise, list items are rendered twice (e.g. /resources, /paper etc. ): https://github.com/vercel/next.js/issues/35822
eslint: {
ignoreDuringBuilds: true, // this allows production builds to successfully complete even if the project has ESLint errors
},
compiler: {
styledComponents: true, // to fix issue where class names on server and client don't match: https://github.com/vercel/next.js/issues/46605#issuecomment-1489135397
},
images: {
// set allowed hosts for the <Image /> component
remotePatterns: [
{
protocol: 'https',
hostname: '**.orkg.org',
},
{
protocol: 'http',
hostname: 'localhost',
},
],
},
webpack(config) {
config.resolve.fallback = {
// if you miss it, all the other options in fallback, specified
// by next.js will be dropped.
...config.resolve.fallback,
fs: false, // the solution
};
config.module.rules.push({
test: /\.md$/,
// This is the asset module.
type: 'asset/source',
});
config.externals = [...config.externals, 'canvas', 'jsdom']; // to fix pdf-text-annotation: https://github.com/kkomelin/isomorphic-dompurify/issues/54
return config;
},
experimental: {
serverComponentsExternalPackages: ['citeproc'],
turbo: {
resolveExtensions: ['.mdx', '.tsx', '.ts', '.jsx', '.js', '.mjs', '.json'],
rules: {
'*.md': {
loaders: ['raw-loader'],
},
},
},
},
output: 'standalone',
env: {
version, // ensure the version is available for display in the footer
},
// redirects for legacy pages, could be removed after a while
async redirects() {
return [
{
source: '/smart-review/new',
destination: '/review/new',
permanent: true,
},
{
source: '/smart-reviews',
destination: '/reviews',
permanent: true,
},
{
source: '/literature-lists',
destination: '/lists',
permanent: true,
},
{
source: '/literature-list/new',
destination: '/list/new',
permanent: true,
},
{
source: '/smart-review/diff/:oldId-:newId',
destination: '/review/diff/:oldId-:newId',
permanent: true,
},
{
source: '/predicate/:id',
destination: '/property/:id',
permanent: true,
},
{
source: '/smart-review/:id',
destination: '/review/:id',
permanent: true,
},
{
source: '/literature-list/:id',
destination: '/list/:id',
permanent: true,
},
{
source: '/literature-list/:id/:embed',
destination: '/list/:id/:embed',
permanent: true,
},
{
source: '/literature-list/diff/:oldId-:newId',
destination: '/list/diff/:oldId/:newId',
permanent: true,
},
{
source: '/tpdl',
destination: '/',
permanent: true,
},
{
source: '/export-data',
destination: '/data',
permanent: true,
},
{
source: '/open-call-curation-grant',
destination: 'https://www.orkg.org/about/28/Curation_Grants',
permanent: true,
},
];
},
};
module.exports = withBundleAnalyzer(nextConfig);