import type { NextConfig } from "next";

const apiUrl = process.env.NEXT_PUBLIC_API_URL ?? "http://127.0.0.1:8000";
const { hostname: apiHostname } = new URL(apiUrl);

const nextConfig: NextConfig = {
  // Long-running Next.js server (`next build` -> `next start`). Content is
  // fetched from cms.akarya.id at request time and cached with ISR, so content
  // edits go live without a rebuild. (Do NOT set `output: "export"` — that
  // freezes content at build time.)
  trailingSlash: true,

  images: {
    remotePatterns: [
      {
        protocol: apiUrl.startsWith("https") ? "https" : "http",
        hostname: apiHostname,
        pathname: "/**",
      },
    ],
  },
};

export default nextConfig;
