// next.config.js
const securityHeaders = [
{ key: 'Strict-Transport-Security', value: 'max-age=63072000; includeSubDomains; preload' },
{ 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-Report-Only',
value: "default-src 'self'; img-src 'self' data: https:; frame-ancestors 'none'" },
]
module.exports = {
poweredByHeader: false,
async headers() {
return [{ source: '/:path*', headers: securityHeaders }]
},
}
Only add preload to HSTS once every subdomain works over the secure connection: it is hard to undo.