NextAuth not working on Cloudflare Pages

I have a Next.js application deployed on Cloudflare pages. I am using NextAuth for login via google and every time I click the login button, /api/auth/providers returns a 404 and I see the error page. This is even after correctly setting the NEXTAUTH_URL and the NEXTAUTH_SECRET.

Does this have something to do with Cloudflare Pages supporting only the Edge runtime? I haven’t set the runtime to edge for my application. Thanks!

Hi, I am having the same issue, have you figured it out?