/** @type {import('next').NextConfig} */
const nextConfig = {
  // Enable standalone output for optimized Docker builds
  output: 'standalone',
  // Note: Body size limits are handled by nginx and backend, not Next.js frontend
  // Removed Next.js rewrites since nginx handles all API routing
  webpack: (config, { isServer }) => {
    // Exclude cheerio and its dependencies from client-side bundling
    if (!isServer) {
      config.resolve.fallback = {
        ...config.resolve.fallback,
        fs: false,
        net: false,
        tls: false,
        'undici': false,
      };
      config.externals.push('cheerio', 'server-only');
    }
    return config;
  },
  images: {
    domains: ['localhost'],
    remotePatterns: [
      {
        protocol: 'http',
        hostname: 'localhost',
        port: '80',
        pathname: '/images/**',
      },
    ],
  },
};

module.exports = nextConfig;