import { type NextRequest } from "next/server";
import { updateSession } from "@/lib/supabase/middleware";

// Supabase SSR uses Node.js APIs (e.g. process.version) which are not
// available in the Edge Runtime. Declaring nodejs runtime here silences
// the build warning and ensures the middleware runs correctly on Node.js.
export const runtime = "nodejs";

export async function middleware(request: NextRequest) {
  return await updateSession(request);
}

export const config = {
  matcher: [
    "/((?!_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)",
  ],
};
