/** @type {import('next').NextConfig} */
const nextConfig = {
  async rewrites() {
    return [
      {
        source: '/api/:path*',
        destination: `${process.env.BACKEND_REWRITE_URL || 'http://localhost:3001'}/api/:path*`
      },
    ];
  },
  images: {
    remotePatterns: [
      {
        protocol: 'https',
        hostname: 'docs-cv-uploads.s3.eu-west-1.amazonaws.com',
        pathname: '/**',
      },
      ...(
        process.env.NODE_ENV === 'development'
          ? [
            {
              protocol: 'http',
              hostname: 'localhost',
              port: '3001',
              pathname: '/uploads/avatars/**',
            },
          ]
          : []
      ),
    ],
  },
};

export default nextConfig;
