-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathnext.config.js
170 lines (166 loc) · 6.1 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
/**
* @type {import('next').NextConfig}
*/
const runtimeCaching = require('next-pwa/cache');
const {
scriptSrcUrls,
workerSrcUrls,
styleSrcUrls,
fontSrcUrls,
imgSrcUrls,
connectSrcUrls,
frameSrcUrls,
} = 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',
});
module.exports = withBundleAnalyzer(
withNextIntl(
withPWA({
reactStrictMode: true,
publicRuntimeConfig: {
NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL,
NEXT_PUBLIC_BASE_URL: process.env.NEXT_PUBLIC_BASE_URL,
NEXT_PUBLIC_VERCEL_BRANCH_URL: process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL,
NEXT_PUBLIC_ENV: process.env.NEXT_PUBLIC_ENV,
NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA,
NEXT_PUBLIC_ROLLBAR_CLIENT_TOKEN: process.env.NEXT_PUBLIC_ROLLBAR_CLIENT_TOKEN,
NEXT_PUBLIC_SIMPLYBOOK_WIDGET_URL: process.env.NEXT_PUBLIC_SIMPLYBOOK_WIDGET_URL,
NEXT_PUBLIC_CRISP_WEBSITE_ID: process.env.NEXT_PUBLIC_CRISP_WEBSITE_ID,
NEXT_PUBLIC_HOTJAR_ID: process.env.NEXT_PUBLIC_HOTJAR_ID,
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID: process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS_ID,
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID: process.env.NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID,
},
compiler: {
emotion: true,
},
images: {
domains: ['a.storyblok.com'],
},
serverExternalPackages: ['newrelic'],
async redirects() {
return [
{
source: '/welcome',
destination: '/courses',
permanent: false,
},
{
source: '/:locale(en|es|de|fr|pt|hi)/welcome',
destination: '/:locale/courses',
permanent: false,
},
{
source: '/login',
destination: '/courses',
permanent: false,
},
{
source: '/:locale(en|es|de|fr|pt|hi)/login',
destination: '/:locale/courses',
permanent: false,
},
{
source: '/partnership/:path*',
destination: '/welcome/:path*',
permanent: true,
},
{
source: '/:locale(en|es|de|fr|pt|hi)/partnership/:path*',
destination: '/:locale/welcome/:path*',
permanent: true,
},
{
source: '/chat',
destination: '/messaging',
permanent: true,
},
{
source: '/:locale(en|es|de|fr|pt|hi)/chat',
destination: '/:locale/messaging',
permanent: true,
},
];
},
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, Crisp iframes, Rollbar, SimplyBook, and Zapier.
// script-src: Allows scripts from the same origin, inline scripts, Google's APIs, Hotjar, Storyblok, and Crisp.
// style-src: Allows styles from the same origin, inline styles, Google's Fonts API, Hotjar, Storyblok, and Crisp.
// font-src: Allows fonts from the same origin and Google's Fonts API.
// img-src: Allows images from the same origin, data URIs, Hotjar, Storyblok, and Crisp.
// connect-src: Allows connections to the same origin, a specified API endpoint, Hotjar, Storyblok, Crisp, Firebase, Rollbar, SimplyBook, and Zapier.
// frame-src: Allows frames from the same origin, Hotjar, Storyblok, and Crisp.
// 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() {
const headers = [
{
source: '/:path',
headers: [
{
key: 'Content-Security-Policy-Report-Only', // Leaving this as report only until we have caught all the CSP violations
value: `
default-src 'self';
script-src 'self' 'unsafe-eval' '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(' ')};
connect-src 'self' ${connectSrcUrls.join(' ')};
frame-src 'self' ${frameSrcUrls.join(' ')};
object-src 'none';
base-uri 'self';
form-action 'self';
frame-ancestors 'self';
`
.replace(/\s{2,}/g, ' ')
.trim(),
},
{
key: 'Referrer-Policy',
value: 'origin-when-cross-origin',
},
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
],
},
];
// This enforces HTTPS for all requests so we don't want this for local development
if (process.env.NODE_ENV === 'production') {
headers[0].headers.push({
key: 'Strict-Transport-Security',
value: 'max-age=31536000; includeSubDomains; preload',
});
}
return headers;
},
}),
),
);