import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  /* config options here */
  async rewrites() {
    const apiUrl = process.env.API_URL || "http://localhost:3001";

    return [
      {
        source: "/api/:path*",
        destination: `${apiUrl}/:path*`
      },
      // WebSocket support for socket.io
      {
        source: "/socket.io/:path*",
        destination: `${apiUrl}/socket.io/:path*`
      }
    ];
  }
};

export default nextConfig;
