Skip to content

Commit c4e535f

Browse files
authored
Merge pull request #211 from supabase/chore/csp
chore: add csp header
2 parents 6d97b28 + 78cf07d commit c4e535f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

website/next.config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
11
/** @type {import('next').NextConfig} */
2+
3+
const cspHeader = `
4+
default-src 'self' ${process.env.NEXT_PUBLIC_SUPABASE_URL};
5+
style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com/ https://fonts.google.com/;
6+
img-src 'self' data: ${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/;
7+
object-src 'none';
8+
base-uri 'none';
9+
frame-ancestors 'none';
10+
`
11+
212
const nextConfig = {
313
reactStrictMode: true,
14+
async headers() {
15+
return [
16+
{
17+
source: '/(.*)',
18+
headers: [
19+
{
20+
key: 'Content-Security-Policy',
21+
value: cspHeader.replace(/\n/g, ''),
22+
},
23+
{
24+
key: 'X-Frame-Options',
25+
value: 'SAMEORIGIN',
26+
},
27+
],
28+
},
29+
]
30+
},
431
}
532

633
module.exports = nextConfig

0 commit comments

Comments
 (0)