-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
next.config.js
120 lines (116 loc) · 3.59 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
// @ts-check
/* eslint-disable @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports */
const { createSecureHeaders } = require("next-secure-headers")
const { withContentlayer } = require("next-contentlayer2")
const port = process.env.PORT || "8080"
const hostname = process.env.HOSTNAME || `localhost`
const domain = process.env.DOMAIN || `http://${hostname}:${port}`
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "standalone",
poweredByHeader: false,
trailingSlash: false,
productionBrowserSourceMaps: true,
reactStrictMode: true,
env: {
DOMAIN: domain,
PORT: port,
},
eslint: {
dirs: ["src", "."],
},
async redirects() {
return [
{
source: "/about",
destination: "https://natwelch.com/wiki/about",
permanent: true,
},
]
},
async headers() {
return [
{
source: "/(.*)",
headers: [
{
key: "NEL",
value: JSON.stringify({ report_to: "default", max_age: 2592000 }),
},
{
key: "Report-To",
value: JSON.stringify({
group: "default",
max_age: 10886400,
endpoints: [
{ url: `https://reportd.natwelch.com/report/writing` },
],
}),
},
{
key: "Reporting-Endpoints",
value: 'default="https://reportd.natwelch.com/reporting/writing"',
},
],
},
{
source: "/(.*)",
headers: createSecureHeaders({
contentSecurityPolicy: {
directives: {
// default-src 'none'
defaultSrc: ["'none'"],
// connect-src https://graphql.natwelch.com/graphql
connectSrc: [
"https://*.natwelch.com",
domain,
domain.replace(/^https?/, "ws"),
"https://*.sentry.io/",
"https://user-events-v3.s3-accelerate.amazonaws.com",
"https://cognito-identity.us-west-2.amazonaws.com",
],
// font-src 'self' https://fonts.gstatic.com
fontSrc: ["'self'", "https://fonts.gstatic.com"],
// img-src 'self' data: https://icco.imgix.net https://storage.googleapis.com
imgSrc: [
"'self'",
"data:",
"https://icco.imgix.net",
"https://storage.googleapis.com",
"https://*.natwelch.com",
],
// script-src 'self' 'unsafe-inline'
scriptSrc: [
"'self'",
"'unsafe-inline'",
"'unsafe-eval'",
"blob:",
"https://*.natwelch.com",
"https://snippet.meticulous.ai",
"https://browser.sentry-cdn.com",
domain,
],
// style-src 'self' 'unsafe-inline' https://fonts.googleapis.com/
styleSrc: [
"'self'",
"'unsafe-inline'",
"https://fonts.googleapis.com/",
],
objectSrc: ["'none'"],
// https://developers.google.com/web/updates/2018/09/reportingapi#csp
reportURI: "https://reportd.natwelch.com/report/writing",
reportTo: "default",
},
reportOnly: false,
},
referrerPolicy: "strict-origin-when-cross-origin",
expectCT: true,
}),
},
]
},
experimental: {
mdxRs: true,
},
}
module.exports = withContentlayer(nextConfig)