-
Notifications
You must be signed in to change notification settings - Fork 53
/
next.config.js
170 lines (162 loc) · 4.63 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
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
})
if (
!process.env.NEXT_PUBLIC_IPFS_GATEWAY ||
!process.env.NEXT_PUBLIC_IPFS_GATEWAY_SAFE
) {
console.log(
"url env variables NEXT_PUBLIC_IPFS_GATEWAY or NEXT_PUBLIC_IPFS_GATEWAY_SAFE are missing"
)
return
}
const urlGateway = new URL(process.env.NEXT_PUBLIC_IPFS_GATEWAY)
const urlGatewaySafe = new URL(process.env.NEXT_PUBLIC_IPFS_GATEWAY_SAFE)
// the main common security headers
const baseSecurityHeaders = [
{
key: "X-Frame-Options",
value: "SAMEORIGIN",
},
// Isolates the browsing context exclusively to same-origin documents.
// Cross-origin documents are not loaded in the same browsing context.
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Opener-Policy
{
key: "Cross-Origin-Opener-Policy",
value: "same-origin",
},
]
const winterUrl = process.env.NEXT_PUBLIC_TZ_NET === "mainnet" ? "https://checkout.usewinter.com/" : "https://sandbox-winter-checkout.onrender.com/"
const articlesAllowedDomains = `https://*.spotify.com/ https://spotify.com https://*.youtube.com/ https://youtube.com https://*.twitter.com/ https://twitter.com https://codepen.io https://openprocessing.org ${winterUrl}`
/** @type {import('next').NextConfig} */
module.exports = withBundleAnalyzer({
reactStrictMode: true,
images: {
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
deviceSizes: [640, 750, 828, 1080, 1200, /*1920, 2048, 3840*/],
domains: [urlGateway.hostname, urlGatewaySafe.hostname]
},
async headers() {
return [
{
source: "/:path*",
headers: [
{
key: "Content-Security-Policy",
value: `frame-ancestors 'self'; frame-src ${process.env.NEXT_PUBLIC_IPFS_GATEWAY_SAFE} ${articlesAllowedDomains} 'self';`,
},
...baseSecurityHeaders,
],
},
{
source: "/sandbox/worker.js",
headers: [
{
key: "service-worker-allowed",
value: "/",
},
],
},
{
source: "/sandbox/preview.html",
headers: [
{
key: "Content-Security-Policy",
value: "",
},
{
key: "Cross-Origin-Embedder-Policy",
value: "require-corp",
},
],
},
]
},
redirects() {
return [
{
source: "/objkt/:params*",
destination: "/gentk/:params*",
permanent: true,
},
// redirects because of the change in the doc structure
{
source: "/articles/about-fxhash",
destination: "/doc/fxhash/overview",
permanent: true,
},
{
source: "/articles/beta",
destination: "/doc/fxhash/beta",
permanent: true,
},
{
source: "/articles/changelog",
destination: "/doc/fxhash/changelog",
permanent: true,
},
{
source: "/articles/code-of-conduct",
destination: "/doc/artist/code-of-conduct",
permanent: true,
},
{
source: "/articles/collect-mint-tokens",
destination: "/doc/collect/guide",
permanent: true,
},
{
source: "/articles/getting-verified",
destination: "/doc/fxhash/verification",
permanent: true,
},
{
source: "/articles/guide-mint-generative-token",
destination: "/doc/artist/guide-publish-generative-token",
permanent: true,
},
{
source: "/articles/integration-guide",
destination: "/doc/fxhash/integration-guide",
permanent: true,
},
{
source: "/articles/moderation-system",
destination: "/doc/fxhash/moderation",
permanent: true,
},
{
source: "/u/:name/activity",
destination: "/u/:name/dashboard/activity",
permanent: true,
},
{
source: "/pkh/:name/activity",
destination: "/pkh/:name/dashboard/activity",
permanent: true,
},
{
source: "/u/:name/creations",
destination: "/u/:name",
permanent: true,
},
{
source: "/pkh/:name/creations",
destination: "/pkh/:name",
permanent: true,
},
{
source: "/explore/articles",
destination: "/articles",
permanent: true,
},
process.env.NEXT_PUBLIC_MAINTENANCE_MODE === "1"
? {
source: "/((?!maintenance|_next).*)",
destination: "/maintenance",
permanent: false,
}
: { source: "/maintenance", destination: "/", permanent: false },
]
},
})