-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
56 lines (54 loc) · 1.4 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
// next.config.js
module.exports = {
async headers() {
return [
{
// Apply these headers to all routes in your application.
source: '/(.*)',
headers: securityHeaders,
},
];
}
};
// Define Content Security Policy
const ContentSecurityPolicy = `
default-src 'self';
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://js.stripe.com;
style-src 'self' 'unsafe-inline';
img-src 'self' https://sandbox-next-stripe-tsc.vercel.app https://generation-sessions.s3.amazonaws.com data:;
media-src 'none';
connect-src 'self' https://cognito-idp.us-east-1.amazonaws.com;
font-src 'self';
frame-src 'self' https://js.stripe.com;
`;
// Define the set of headers
const securityHeaders = [
{
key: 'Content-Security-Policy',
value: ContentSecurityPolicy.replace(/\n/g, ''), // remove newlines
},
{
key: 'Referrer-Policy',
value: 'origin-when-cross-origin',
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'X-DNS-Prefetch-Control',
value: 'on',
},
{
key: 'Permissions-Policy',
value: 'camera=(), microphone=(), geolocation=()',
},
{
key: 'X-XSS-Protection',
value: '1; mode=block',
},
];