import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  turbopack: {
    root: __dirname,
  },
  allowedDevOrigins: ["http://localhost:3000"],
  images: {
    remotePatterns: [
      {
        protocol: "https",
        hostname: "lh3.googleusercontent.com",
      },
      {
        protocol: "https",
        hostname: "scontent.famd5-1.fna.fbcdn.net",
      },
      {
        protocol: "https",
        hostname: "reelflix.b-cdn.net",
      },
      {
        protocol: "https",
        hostname: "reelflix-archana2.b-cdn.net",
      },
      {
        protocol: "https",
        hostname: "reelflix-test.b-cdn.net",
      },
      {
        protocol: "https",
        hostname: "reelflix-development-new.b-cdn.net",
      },
      {
        protocol: "https",
        hostname: "*.b-cdn.net",
      },

      // ✅ Add Facebook CDN Variants
      {
        protocol: "https",
        hostname: "*.fbcdn.net",
      },
      {
        protocol: "https",
        hostname: "*.fna.fbcdn.net",
      },
      {
        protocol: "https",
        hostname: "*.xx.fbcdn.net",
      },
      {
        protocol: "https",
        hostname: "scontent-bom2-1.xx.fbcdn.net",
      },
      {
        protocol: "https",
        hostname: "s3.eu-south-1.wasabisys.com",
      },
      {
        protocol: "https",
        hostname: "vz-bb070104-335.b-cdn.net",
      },
      {
        protocol: "https",
        hostname: "reelflix-s3.s3.ap-south-1.amazonaws.com",
      }
    ],
    // AVIF first, WebP as the fallback — posters and backdrops are the bulk of
    // the bytes on every page.
    formats: ["image/avif", "image/webp"],
    // CDN asset URLs are stable, so there is no reason to re-optimize them
    // every minute.
    minimumCacheTTL: 60 * 60 * 24 * 30,
  },
};

export default nextConfig;
