-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
61 lines (55 loc) · 1.39 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
const { PHASE_DEVELOPMENT_SERVER } = require("next/constants");
module.exports = (phase) => {
/**
* @type {import('next').NextConfig}
*/
const config = {
reactStrictMode: true,
async headers() {
const csp = {
"base-uri": [`'none'`],
"object-src": [`'none'`],
"frame-src": [
"https://js.stripe.com",
"https://edge-js.stripe.com",
"http://localhost:*",
"https://*.stripe.me",
"https://hooks.stripe.com",
],
"script-src": [
`'self'`,
"https://js.stripe.com",
"https://edge-js.stripe.com",
"http://localhost:*",
"https://*.stripe.me",
"https://maps.googleapis.com",
],
"connect-src": [
`'self'`,
"https://api.stripe.com",
"https://maps.googleapis.com",
],
};
if (phase === PHASE_DEVELOPMENT_SERVER) {
csp["script-src"].push(`'unsafe-eval'`);
}
const cspHeaderValue = Object.entries(csp).reduce(
(acc, [directive, values]) =>
`${acc}; ${directive} ${values.join(" ")}`,
""
);
return [
{
source: "/:path*",
headers: [
{
key: "Content-Security-Policy",
value: cspHeaderValue,
},
],
},
];
},
};
return config;
};