import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  serverExternalPackages: ["pdfkit"],
  images: {
    remotePatterns: [
      {
        protocol: "https",
        hostname: "images.unsplash.com",
      },
    ],
  },
  async rewrites() {
    return {
      beforeFiles: [
        {
          source: "/uploads/:path*",
          destination: "/api/uploads/:path*",
        },
      ],
      fallback: [
        {
          source: "/en",
          destination: "/",
        },
        {
          source: "/ar",
          destination: "/",
        },
        {
          source: "/en/:path((?!admin|api).*)",
          destination: "/:path*",
        },
        {
          source: "/ar/:path((?!admin|api).*)",
          destination: "/:path*",
        },
      ]
    };
  },
};

export default nextConfig;
