- X-Frame-Options/CSP frame-ancestors gegen Clickjacking, nosniff, Referrer-Policy, Permissions-Policy - Origin-Check als CSRF-Defense-in-Depth für /api/admin/users und /logout (zusätzlich zu SameSite=Lax-Cookies und JSON-Content-Type)
29 lines
897 B
TypeScript
29 lines
897 B
TypeScript
import type { NextConfig } from "next";
|
|
|
|
// HTTP-Security-Header für alle Routen.
|
|
// HTTPS/HSTS übernimmt im Live-Betrieb der Reverse-Proxy.
|
|
const securityHeaders = [
|
|
// Verhindert Einbettung in fremde Seiten (Clickjacking)
|
|
{ key: "X-Frame-Options", value: "DENY" },
|
|
{ key: "Content-Security-Policy", value: "frame-ancestors 'none'" },
|
|
// Browser darf Content-Types nicht "erraten"
|
|
{ key: "X-Content-Type-Options", value: "nosniff" },
|
|
// Keine vollständigen URLs an fremde Seiten weitergeben
|
|
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
|
|
// Sensorische APIs werden nicht benötigt
|
|
{ key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=()" },
|
|
];
|
|
|
|
const nextConfig: NextConfig = {
|
|
async headers() {
|
|
return [
|
|
{
|
|
source: "/(.*)",
|
|
headers: securityHeaders,
|
|
},
|
|
];
|
|
},
|
|
};
|
|
|
|
export default nextConfig;
|