-
Notifications
You must be signed in to change notification settings - Fork 209
/
next.config.js
212 lines (200 loc) · 5.95 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
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint @typescript-eslint/no-var-requires: "off" */
import { withSentryConfig } from "@sentry/nextjs";
/** @type {import('next').NextConfig} */
const nextConfig = {
productionBrowserSourceMaps: true,
images: {
remotePatterns: [
{
protocol: "http",
hostname: "localhost",
port: "6060",
},
{
protocol: "https",
hostname: "fx-breach-alerts.herokuapp.com/",
},
{
protocol: "https",
hostname: "stage.firefoxmonitor.nonprod.cloudops.mozgcp.net",
},
{
protocol: "https",
hostname: "monitor.firefox.com",
},
{
protocol: "https",
hostname: "monitor.mozilla.org",
},
{
protocol: "https",
hostname: "firefoxusercontent.com",
},
{
protocol: "https",
hostname: "profile.stage.mozaws.net",
},
{
protocol: "https",
hostname: "profile.accounts.firefox.com",
},
// Stores breached companies' logos
{
protocol: "https",
hostname: "s3.amazonaws.com",
},
],
},
/** @type {import('next').NextConfig['headers']} */
async headers() {
const headers = [
{
source: "/:path*",
headers: [
// Note: the Content-Security-Policy gets set in /src/middleware.ts
// (because it needs a dynamically-generated nonce).
{
key: "Cross-Origin-Opener-Policy",
value: "same-origin",
},
{
key: "Cross-Origin-Resource-Policy",
value: "cross-origin",
},
{
key: "Referrer-Policy",
value: "no-referrer, strict-origin-when-cross-origin",
},
{
key: "Origin-Agent-Cluster",
value: "?1",
},
{
key: "Strict-Transport-Security",
value: "max-age=15552000; includeSubDomains",
},
{
key: "X-Content-Type-Options",
value: "nosniff",
},
{
key: "X-DNS-Prefetch-Control",
value: "off",
},
{
key: "X-Download-Options",
value: "noopen",
},
{
key: "X-Frame-Options",
value: "SAMEORIGIN",
},
{
key: "X-Permitted-Cross-Domain-Policies",
value: "none",
},
{
key: "X-XSS-Protection",
value: "0",
},
],
},
];
const noindexEnvs = ["dev", "development", "heroku", "stage"];
const noSearchEngineIndex = noindexEnvs.includes(process.env.NODE_ENV);
if (noSearchEngineIndex) {
headers.push({
source: "/:path*",
headers: [
{
key: "X-Robots-Tag",
value: "noindex",
},
],
});
}
return headers;
},
async redirects() {
return [
// Before we redesigned the website, the dashboard would be reachable
// via /user/breaches:
{
source: "/user/breaches",
destination: "/user/dashboard",
permanent: true,
},
// While we were implementing a redesign, we made it available at the
// /redesign subpath. In case we still have lingering links to there
// anywhere, this redirect should have people end up at the right place:
{
source: "/redesign/:path*",
destination: "/:path*",
permanent: true,
},
{
source: "/user/dashboard/fix/data-broker-profiles/welcome-to-premium",
destination: "/user/dashboard/fix/data-broker-profiles/welcome-to-plus",
permanent: true,
},
// We used to have a page with security tips;
// if folks get sent there via old lnks, redirect them to the most
// relevant page on SuMo:
{
source: "/security-tips",
destination: "https://support.mozilla.org/kb/how-stay-safe-web",
permanent: false,
},
// Some subset of users still find their way to the old login
// link, which redirects to a now-404 endpoint. Add a redirect
// to the new endpoint while we are investigating.
{
source: "/oauth/confirmed",
destination: "/api/auth/callback/fxa",
permanent: false,
},
];
},
webpack: (config, _options) => {
config.module.rules.push({
test: /\.ftl/,
type: "asset/source",
});
config.externals ??= {};
config.externals.push({
knex: "commonjs knex",
});
return config;
},
experimental: {
// Without this setting, Next.js has Webpack trying and failing to load
// uglify-js when compiling MJML email templates to HTML in `renderEmail.ts`:
serverComponentsExternalPackages: ["mjml"],
// Sentry 8.x requires `instrumentation.ts` vs. it's previous custom approach.
instrumentationHook: true,
},
};
const sentryOptions = {
// Additional config options for the Sentry Webpack plugin. Keep in mind that
// the following options are set automatically, and overriding them is not
// recommended:
// release, url, authToken, configFile, stripPrefix,
// urlPrefix, include, ignore
org: "mozilla",
project: "firefox-monitor",
silent: false, // Suppresses all logs
authToken: process.env.SENTRY_AUTH_TOKEN,
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
// Upload additional client files (increases upload size)
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#widen-the-upload-scope
widenClientFileUpload: true,
hideSourceMaps: false,
sourcemaps: {
disable: process.env.UPLOAD_SENTRY_SOURCEMAPS === "false",
},
};
export default withSentryConfig(nextConfig, sentryOptions);