-
-
Notifications
You must be signed in to change notification settings - Fork 155
/
next.config.js
executable file
·117 lines (109 loc) · 3.2 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
const { locales, defaultLocale } = require("./data/locales.js")
function notIfProduction(param) {
if (process.env.NODE_ENV === "production") return ""
else return param
}
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
i18n: {
locales: locales.map((l) => l.code),
defaultLocale,
},
images: {
remotePatterns: [
{ hostname: "proxy.joinmastodon.org" },
{ hostname: "c8.patreon.com" },
{ hostname: "c10.patreonusercontent.com" },
],
},
async headers() {
// These static files are references with hardcoded URLs and need proper Cache-Control headers
return [
"/fonts/:all*(ttf|otf|woff|woff2)",
"/favicon-:all*(png)",
"/app-icon.png",
"/preview.png",
]
.map((source) => ({
source,
headers: [
{
key: "Cache-control",
value: "max-age=3600, stale-while-revalidate",
},
],
}))
.concat({
source: "/(.*)?",
headers: [
{
key: "X-Content-Type-Options",
value: "nosniff",
},
{
key: "Permissions-Policy",
value:
"camera=(), microphone=(), geolocation=(), browsing-topics=()",
},
{
key: "Referrer-Policy",
value: "origin-when-cross-origin",
},
{
key: "Content-Security-Policy",
value: `default-src 'self'; child-src 'none'; object-src 'none'; img-src 'self' proxy.joinmastodon.org blob: data:; style-src 'self' 'unsafe-inline'; script-src 'self' ${notIfProduction("'unsafe-inline' 'unsafe-eval'")}; connect-src 'self' api.joinmastodon.org; block-all-mixed-content`,
},
],
})
},
async redirects() {
return [
{
source: "/communities",
destination: "/servers",
permanent: true,
},
{
source: "/imprint",
destination: "/about#impressum",
permanent: true,
},
{
source: "/impressum",
destination: "/about#impressum",
permanent: true,
},
]
},
webpack(config, { isServer, isdev }) {
// Grab the existing rule that handles SVG imports
const fileLoaderRule = config.module.rules.find(
(rule) => rule.test && rule.test.test?.(".svg")
)
config.module.rules.push({
oneOf: [
// warning: do not specify `issuer` key here, it is broken with dynamic require
// see https://github.com/webpack/webpack/issues/9309
// https://github.com/vercel/next.js/discussions/15437
{
test: /\.svg$/i,
resourceQuery: /inline/, // Only for *.svg?inline
use: [{ loader: "@svgr/webpack", options: { svgo: false } }],
},
// we need to add this, as the previous rule disabled the default SVG loader
{
...fileLoaderRule,
test: /\.svg$/i,
resourceQuery: { not: [/inline/] },
},
],
})
// Modify the file loader rule to ignore *.svg, since we have it handled now.
fileLoaderRule.exclude = /\.svg$/i
return config
},
poweredByHeader: false,
output: "standalone",
}
module.exports = nextConfig