mirror of
https://github.com/bitbaum/botsmann.git
synced 2026-12-04 05:08:02 +01:00
feat(security): add security headers via next.config.js
Add CSP, HSTS (1 year), X-Content-Type-Options, X-Frame-Options, Referrer-Policy, and Permissions-Policy headers to all routes. CSP allows required external sources (Groq, OpenRouter, Supabase, GitHub, YouTube, Giscus). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
aa515d3d89
commit
06531355bf
1 file changed
+57
-20
+57
-20
@@ -45,26 +45,63 @@ const nextConfig = {
|
||||
},
|
||||
];
|
||||
},
|
||||
headers: async () => [
|
||||
{
|
||||
source: '/api/:path*',
|
||||
headers: [
|
||||
{
|
||||
key: 'Cache-Control',
|
||||
value: 'no-store, max-age=0',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
source: '/((?!api).*)',
|
||||
headers: [
|
||||
{
|
||||
key: 'Cache-Control',
|
||||
value: 'public, max-age=3600, s-maxage=86400, stale-while-revalidate=60',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
headers: async () => {
|
||||
const securityHeaders = [
|
||||
{
|
||||
key: 'Strict-Transport-Security',
|
||||
value: 'max-age=31536000; includeSubDomains',
|
||||
},
|
||||
{
|
||||
key: 'X-Content-Type-Options',
|
||||
value: 'nosniff',
|
||||
},
|
||||
{
|
||||
key: 'X-Frame-Options',
|
||||
value: 'DENY',
|
||||
},
|
||||
{
|
||||
key: 'Referrer-Policy',
|
||||
value: 'strict-origin-when-cross-origin',
|
||||
},
|
||||
{
|
||||
key: 'Permissions-Policy',
|
||||
value: 'camera=(), microphone=(), geolocation=()',
|
||||
},
|
||||
{
|
||||
key: 'Content-Security-Policy',
|
||||
value: [
|
||||
"default-src 'self'",
|
||||
"script-src 'self' 'unsafe-inline' 'unsafe-eval' https://giscus.app https://platform.twitter.com",
|
||||
"style-src 'self' 'unsafe-inline'",
|
||||
"img-src 'self' data: blob: https://raw.githubusercontent.com https://images.unsplash.com",
|
||||
"font-src 'self'",
|
||||
"connect-src 'self' https://api.groq.com https://openrouter.ai https://api.openai.com https://api.github.com https://raw.githubusercontent.com https://*.supabase.co",
|
||||
"frame-src 'self' https://www.youtube.com https://giscus.app",
|
||||
"frame-ancestors 'none'",
|
||||
].join('; '),
|
||||
},
|
||||
];
|
||||
|
||||
return [
|
||||
{
|
||||
source: '/api/:path*',
|
||||
headers: [{ key: 'Cache-Control', value: 'no-store, max-age=0' }],
|
||||
},
|
||||
{
|
||||
source: '/(.*)',
|
||||
headers: securityHeaders,
|
||||
},
|
||||
{
|
||||
source: '/((?!api).*)',
|
||||
headers: [
|
||||
{
|
||||
key: 'Cache-Control',
|
||||
value: 'public, max-age=3600, s-maxage=86400, stale-while-revalidate=60',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = nextConfig;
|
||||
Reference in new issue
Block a user