import type { NextConfig } from "next";

const backendInternalUrl = (process.env.BACKEND_INTERNAL_URL ?? "http://127.0.0.1:8000").replace(
  /\/$/,
  "",
);

const nextConfig: NextConfig = {
  output: "standalone",
  async rewrites() {
    return [
      { source: "/health", destination: `${backendInternalUrl}/health` },
      { source: "/api/:path*", destination: `${backendInternalUrl}/api/:path*` },
    ];
  },
};

export default nextConfig;
