import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  // Allow cross-origin dev requests from proxy
  allowedDevOrigins: ["jml", "http://jml"],

  // Proxy API requests to backend in development
  async rewrites() {
    return [
      {
        source: "/v1/:path*",
        destination: "http://127.0.0.1:18180/v1/:path*",
      },
      {
        source: "/health",
        destination: "http://127.0.0.1:18180/health",
      },
      {
        source: "/metrics",
        destination: "http://127.0.0.1:18180/metrics",
      },
      {
        source: "/swagger-ui/:path*",
        destination: "http://127.0.0.1:18180/swagger-ui/:path*",
      },
      {
        source: "/api-docs/:path*",
        destination: "http://127.0.0.1:18180/api-docs/:path*",
      },
    ];
  },
};

export default nextConfig;
