/** @type {import('next').NextConfig} */

const isProduction = process.env.NEXT_PUBLIC_APP_MODE === "production";

const nextConfig = {
  ...(isProduction && {
    async redirects() {
      return [
        {
          source: "/:path*",
          has: [
            {
              type: "host",
              value: "kleboai.com",
            },
          ],
          destination: "https://www.kleboai.com/:path*",
          permanent: true,
        },
      ];
    },
  }),

  images: {
    remotePatterns: isProduction
      ? [
          {
            protocol: "http",
            hostname: "localhost",
            port: "8000",
            pathname: "/storage/**",
          },
          {
            protocol: "https",
            hostname: "api.kleboai.com",
            pathname: "/storage/**",
          },
        ]
      : [
          {
            protocol: "http",
            hostname: "localhost",
            port: "8000",
            pathname: "/storage/**",
          },
          {
            protocol: "https",
            hostname: "kleboai.hipl-staging2.com",
            pathname: "/storage/**",
          },
        ],
  },
};

export default nextConfig;
