import type { NextConfig } from "next";
import { dirname } from "path";
import { fileURLToPath } from "url";
import { SECURITY_HEADERS } from "./src/lib/security/headers";

const __dirname = dirname(fileURLToPath(import.meta.url));

const nextConfig: NextConfig = {
  output: "standalone",
  outputFileTracingRoot: __dirname,
  poweredByHeader: false,
  experimental: { authInterrupts: true }, // erlaubt forbidden() aus next/navigation
  async headers() {
    return [
      {
        source: "/(.*)",
        headers: Object.entries(SECURITY_HEADERS).map(([key, value]) => ({
          key,
          value,
        })),
      },
    ];
  },
};

export default nextConfig;
