-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnext.config.js
53 lines (45 loc) · 923 Bytes
/
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
const fetch = require('node-fetch')
module.exports = {
async redirects() {
const urls = await fetch(process.env.apiURL).then((x) => x.json())
const redirects = urls.map((x) => ({
permanent: true,
source: `/${x.name}/:wildcards*`,
destination: `${x.url}/:wildcards*`,
}))
if (process.env.baseUrl) {
redirects.push({
permanent: true,
source: '/',
destination: `${process.env.baseUrl}`,
})
}
console.log(redirects)
return redirects
},
async rewrites() {
const rewrites = []
if (!process.env.baseUrl) {
rewrites.push({
source: '/',
destination: '/list',
})
}
if (process.env.list) {
rewrites.push({
source:
process.env.list[0] === '/'
? process.env.list
: `/${process.env.list}`,
destination: '/list',
})
}
return rewrites
},
github: {
autoAlias: true,
enabled: true,
},
trailingSlash: false,
public: true,
}