/** @type {import('next').NextConfig} */
const nextConfig = {
  reactCompiler: true,
  images: {
    remotePatterns: [
      {
        protocol: 'https',
        hostname: 'images.unsplash.com',
      },
      {
        protocol: 'https',
        hostname: 'placehold.co',
      },
    ],
  },
  transpilePackages: ['lucide-react'],
  experimental: {
    optimizePackageImports: ['lucide-react'],
    // turbopackFileSystemCacheForDev: true,
  },

  async rewrites() {
    const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL;

    if (!API_BASE_URL) {
      console.error("Error: NEXT_PUBLIC_API_URL is not defined in .env file, Proxy will not function.");
      return [];
    }

    return [
      {
        source: '/api/v1/:path*',
        destination: `${API_BASE_URL}/:path*`,
      },
    ];
  },
};

module.exports = nextConfig;