Skip to content

Commit d85c06c

Browse files
authored
Merge pull request #99 from DurianPy-Davao-Python-User-Group/DY-91
feat: add security headers configuration to next.js setup
2 parents 4aab144 + 063c10e commit d85c06c

1 file changed

Lines changed: 59 additions & 1 deletion

File tree

next.config.mjs

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,62 @@
11
/** @type {import('next').NextConfig} */
2-
const nextConfig = {};
2+
const nextConfig = {
3+
poweredByHeader: false,
4+
async headers() {
5+
return [
6+
{
7+
source: '/(.*)',
8+
headers: [
9+
{
10+
key: 'strict-transport-security',
11+
value: 'max-age=31536000; includeSubDomains; preload',
12+
},
13+
{
14+
key: 'content-security-policy',
15+
value: `
16+
default-src 'self';
17+
script-src 'report-sample' 'self' 'unsafe-inline' 'unsafe-eval';
18+
style-src 'report-sample' 'self' 'unsafe-inline' https://fonts.googleapis.com;
19+
object-src 'none';
20+
base-uri 'self';
21+
connect-src 'self';
22+
font-src 'self' https://fonts.gstatic.com;
23+
frame-src 'self' https://docs.google.com;
24+
img-src 'self';
25+
manifest-src 'self';
26+
media-src 'self';
27+
worker-src 'none';
28+
`
29+
.replace(/\s+/g, ' ')
30+
.trim(),
31+
},
32+
{
33+
key: 'x-frame-options',
34+
value: 'SAMEORIGIN',
35+
},
36+
{
37+
key: 'x-content-type-options',
38+
value: 'nosniff',
39+
},
40+
{
41+
key: 'referrer-policy',
42+
value: 'strict-origin-when-cross-origin',
43+
},
44+
{
45+
key: 'permissions-policy',
46+
value: `
47+
camera=(),
48+
microphone=(),
49+
geolocation=(),
50+
usb=(),
51+
payment=()
52+
`
53+
.replace(/\s+/g, ' ')
54+
.trim(),
55+
},
56+
],
57+
},
58+
];
59+
},
60+
};
361

462
export default nextConfig;

0 commit comments

Comments
 (0)