import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  reactStrictMode: true,
  serverExternalPackages: ["@node-rs/argon2", "@prisma/client", "embedded-postgres"],
  experimental: {
    serverActions: {
      bodySizeLimit: "12mb",
    },
    // Shared hosting caps memory per account. Next spawns one build worker per
    // CPU (15 on the deployment host), and the parallel `Collecting page data`
    // phase gets SIGKILLed by the OOM killer. Cap it and ask Webpack to trade
    // a little speed for a smaller peak footprint.
    cpus: 2,
    webpackMemoryOptimizations: true,
  },
  typescript: {
    ignoreBuildErrors: false,
  },
  async headers() {
    return [
      {
        source: "/:path*",
        headers: [
          { key: "X-Content-Type-Options", value: "nosniff" },
          { key: "X-Frame-Options", value: "SAMEORIGIN" },
          { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
          { key: "X-DNS-Prefetch-Control", value: "on" },
        ],
      },
    ];
  },
};

export default nextConfig;
