Repository navigation
Expand file tree
/
Copy pathnext.config.js
More file actions
237 lines (233 loc) · 7.86 KB
/
Copy pathnext.config.js
File metadata and controls
237 lines (233 loc) · 7.86 KB
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/**
* @type {import('next').NextConfig}
*/
const runtimeCaching = require('next-pwa/cache');
const {
scriptSrcUrls,
workerSrcUrls,
styleSrcUrls,
fontSrcUrls,
imgSrcUrls,
connectSrcUrls,
frameSrcUrls,
mediaSrcUrls,
frameAncestorsUrls,
} = require('./scriptUrls');
const withNextIntl = require('next-intl/plugin')();
const withPWA = require('next-pwa')({
dest: 'public',
runtimeCaching,
buildExcludes: ['app-build-manifest.json'],
disable: process.env.NODE_ENV === 'development',
});
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
// The locale segment of the prefixed paths below. Mirrors routing.locales in i18n/routing.ts.
const LOCALE_PATTERN = ':locale(en|es|de|fr|pt|hi|ar|tr)';
module.exports = withBundleAnalyzer(
withNextIntl(
withPWA({
reactStrictMode: true,
compiler: {
emotion: true,
},
images: {
remotePatterns: [{ protocol: 'https', hostname: 'a.storyblok.com' }],
},
serverExternalPackages: ['newrelic'],
async redirects() {
return [
{
source: '/welcome',
destination: '/library',
permanent: false,
},
{
source: `/${LOCALE_PATTERN}/welcome`,
destination: '/:locale/library',
permanent: false,
},
{
source: '/login',
destination: '/library',
permanent: false,
},
{
source: `/${LOCALE_PATTERN}/login`,
destination: '/:locale/library',
permanent: false,
},
{
source: '/partnership/:path*',
destination: '/welcome/:path*',
permanent: true,
},
{
source: `/${LOCALE_PATTERN}/partnership/:path*`,
destination: '/:locale/welcome/:path*',
permanent: true,
},
{
source: '/chat',
destination: '/messaging',
permanent: true,
},
{
source: `/${LOCALE_PATTERN}/chat`,
destination: '/:locale/messaging',
permanent: true,
},
{
source: '/activities',
destination: '/library?format=activity',
permanent: true,
},
{
source: `/${LOCALE_PATTERN}/activities`,
destination: '/:locale/library?format=activity',
permanent: true,
},
// Video resources live under /video, audio under /audio; these keep older links working.
{
source: '/shorts/:slug',
destination: '/video/:slug',
permanent: true,
},
{
source: `/${LOCALE_PATTERN}/shorts/:slug`,
destination: '/:locale/video/:slug',
permanent: true,
},
{
source: '/videos/:slug',
destination: '/video/:slug',
permanent: true,
},
{
source: `/${LOCALE_PATTERN}/videos/:slug`,
destination: '/:locale/video/:slug',
permanent: true,
},
{
source: '/conversations/:slug',
destination: '/audio/:slug',
permanent: true,
},
{
source: `/${LOCALE_PATTERN}/conversations/:slug`,
destination: '/:locale/audio/:slug',
permanent: true,
},
{
source: '/about-our-courses',
destination: '/library',
permanent: false,
},
// The old Courses landing route; individual course pages are unaffected.
{
source: '/courses',
destination: '/library',
permanent: false,
},
{
source: `/${LOCALE_PATTERN}/courses`,
destination: '/:locale/library',
permanent: false,
},
];
},
async rewrites() {
return [
{
source: '/welcome/(b|B)(a|A)(d|D)(o|O)(o|O)',
destination: '/welcome/badoo',
},
{
source: '/welcome/(b|B)(u|U)(m|M)(b|B)(l|L)(e|E)',
destination: '/welcome/bumble',
},
{
source: '/welcome/(f|F)(r|R)(u|U)(i|I)(t|T)(z|Z)',
destination: '/welcome/fruitz',
},
];
},
// Content-Security-Policy Header: The Content-Security-Policy header is updated to include the necessary directives for Firebase API, Front Chat, Rollbar, SimplyBook, and Zapier.
// script-src: Allows scripts from the same origin, inline scripts, Google's APIs, Hotjar, Storyblok, and Front Chat.
// style-src: Allows styles from the same origin, inline styles, Google's Fonts API, Hotjar, and Storyblok.
// font-src: Allows fonts from the same origin, Google's Fonts API, and Front Chat.
// img-src: Allows images from the same origin, data URIs, Hotjar, Storyblok, and Front Chat.
// connect-src: Allows connections to the same origin, a specified API endpoint, Hotjar, Storyblok, Front Chat, Firebase, Rollbar, SimplyBook, and Zapier.
// frame-src: Allows frames from the same origin, Hotjar, and Storyblok.
// object-src: Disallows all object sources.
// base-uri: Restricts the base URI to the same origin.
// form-action: Restricts form actions to the same origin.
// frame-ancestors: Restricts embedding to the same origin.
async headers() {
return [
{
source: '/(.*)',
headers: [
{
key: 'Content-Security-Policy',
value: `
default-src 'self';
script-src 'self' 'unsafe-inline' ${scriptSrcUrls.join(' ')};
child-src 'self' blob:;
worker-src 'self' ${workerSrcUrls.join(' ')};
style-src 'self' 'unsafe-inline' ${styleSrcUrls.join(' ')};
font-src 'self' ${fontSrcUrls.join(' ')};
img-src 'self' data: ${imgSrcUrls.join(' ')};
media-src 'self' ${mediaSrcUrls.join(' ')};
connect-src 'self' ${connectSrcUrls.join(' ')};
frame-src 'self' ${frameSrcUrls.join(' ')};
object-src 'none';
base-uri 'self';
form-action 'self';
frame-ancestors ${frameAncestorsUrls.join(' ')};
upgrade-insecure-requests;
`
.replace(/\s{2,}/g, ' ')
.trim(),
},
{
key: 'Referrer-Policy',
value: 'strict-origin-when-cross-origin',
},
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
{
key: 'X-XSS-Protection',
value: '1; mode=block',
},
{
key: 'Permissions-Policy',
value:
'camera=(), microphone=(self), geolocation=(), usb=(), bluetooth=(), payment=(), accelerometer=(), gyroscope=(), magnetometer=(), ambient-light-sensor=(), autoplay=(self "https://www.youtube-nocookie.com" "https://www.youtube.com")',
},
{
key: 'Cross-Origin-Opener-Policy',
value: 'same-origin-allow-popups',
},
...(process.env.NODE_ENV === 'production'
? [
{
key: 'Strict-Transport-Security',
value: 'max-age=31536000; includeSubDomains; preload',
},
]
: []),
],
},
];
},
}),
),
);