051d0ce469
* security hardening pass 1 - otel removed * hardening pass #2 * feat security hardening pass * chore: trim unrelated docs from security hardening pr * fix: address security hardening review findings * address findings
63 lines
1.4 KiB
TypeScript
63 lines
1.4 KiB
TypeScript
import type { NextConfig } from "next";
|
|
|
|
const securityHeaders = [
|
|
{
|
|
key: "Content-Security-Policy",
|
|
value: [
|
|
"default-src 'self'",
|
|
"base-uri 'self'",
|
|
"form-action 'self'",
|
|
"frame-ancestors 'self'",
|
|
"img-src 'self' data: blob: http: https:",
|
|
"font-src 'self' data: https:",
|
|
"style-src 'self' 'unsafe-inline' https:",
|
|
"script-src 'self' 'unsafe-inline' 'unsafe-eval' blob:",
|
|
"connect-src 'self' ws: wss: http: https:",
|
|
"media-src 'self' blob: data: http: https:",
|
|
"worker-src 'self' blob:",
|
|
"object-src 'none'",
|
|
"upgrade-insecure-requests",
|
|
].join("; "),
|
|
},
|
|
{
|
|
key: "Referrer-Policy",
|
|
value: "strict-origin-when-cross-origin",
|
|
},
|
|
{
|
|
key: "X-Content-Type-Options",
|
|
value: "nosniff",
|
|
},
|
|
{
|
|
key: "X-Frame-Options",
|
|
value: "SAMEORIGIN",
|
|
},
|
|
{
|
|
key: "Permissions-Policy",
|
|
value: "camera=(), microphone=(self), geolocation=(), browsing-topics=()",
|
|
},
|
|
{
|
|
key: "Cross-Origin-Resource-Policy",
|
|
value: "same-origin",
|
|
},
|
|
];
|
|
|
|
if (process.env.NODE_ENV === "production") {
|
|
securityHeaders.push({
|
|
key: "Strict-Transport-Security",
|
|
value: "max-age=31536000; includeSubDomains",
|
|
});
|
|
}
|
|
|
|
const nextConfig: NextConfig = {
|
|
async headers() {
|
|
return [
|
|
{
|
|
source: "/:path*",
|
|
headers: securityHeaders,
|
|
},
|
|
];
|
|
},
|
|
};
|
|
|
|
export default nextConfig;
|