import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  output: "standalone",
  compress: true,
  poweredByHeader: false,
  experimental: {
    cpus: 1,
    workerThreads: false,
    proxyClientMaxBodySize: "1gb",
    serverActions: {
      bodySizeLimit: "1gb",
    },
  },
  typescript: {
    ignoreBuildErrors: true,
  },
  eslint: {
    ignoreDuringBuilds: true,
  },
  images: {
    remotePatterns: [
      { protocol: "https", hostname: "ei.phncdn.com" },
      { protocol: "https", hostname: "**.phncdn.com" },
      { protocol: "https", hostname: "**.pornhub.com" },
    ],
    unoptimized: true,
  },
  async headers() {
    return [
      {
        source: "/_next/static/(.*)",
        headers: [
          {
            key: "Cache-Control",
            value: "public, max-age=31536000, immutable",
          },
        ],
      },
      {
        source: "/(.*)",
        headers: [
          {
            key: "Content-Security-Policy",
            value: [
              "default-src 'self' https: data: blob:",
              "script-src 'self' 'unsafe-inline' 'unsafe-eval' https: http:",
              "style-src 'self' 'unsafe-inline' https://fonts.googleapis.com",
              "font-src 'self' https://fonts.gstatic.com",
              "img-src 'self' data: blob: https: http:",
              "media-src 'self' blob: https: http:",
              "frame-src * 'self' data: blob: https: http:",
              "connect-src 'self' https: http:",
            ].join("; "),
          },
        ],
      },
    ];
  },
  async rewrites() {
    return [
      {
        source: "/dmca",
        destination: "/legal/dmca",
      },
      {
        source: "/2257",
        destination: "/legal/2257",
      },
      {
        source: "/sitemap-:slug.xml",
        destination: "/api/sitemaps/:slug",
      },
      {
        source: "/sitemaps/:slug.xml",
        destination: "/api/sitemaps/:slug",
      },
    ];
  },
};

export default nextConfig;
