/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    serverComponentsExternalPackages: ['sharp'],
  },
  images: {
    remotePatterns: [
      { protocol: 'https', hostname: '**' },
    ],
  },
  async rewrites() {
    const rules = [
      { source: '/calendar.ics', destination: '/calendar' },
    ];
    if (process.env.NODE_ENV === 'development') {
      rules.push({
        source: '/api/:path*',
        destination: 'http://127.0.0.1:4000/api/:path*',
      });
    }
    return rules;
  },
};

module.exports = nextConfig;
