import createMiddleware from "next-intl/middleware";
import { NextRequest } from "next/server";
import { routing } from "./i18n/routing";

const handleI18nRouting = createMiddleware(routing);

export default function proxy(req: NextRequest) {
  // CRITICAL: Skip API routes entirely - they should not go through i18n middleware
  if (req.nextUrl.pathname.startsWith("/api/")) {
    return; // Return undefined to pass through without modification
  }

  // All pages are public - no auth required
  return handleI18nRouting(req);
}

export const config = {
  matcher: "/((?!api|trpc|_next|_vercel|.*\\..*).*)",
};
