Getting 405 on Vercel

I am trying make betterauth to work on Vercel, but for some reason all calls to /api/auth/* return 405 Method Not Allowed. Works locally, other endpoints work on Vercel. Using Next.js 15 and better auth v1.2.12
Solution:
Oh nevermind, I had incorrectly configured vercel.json file with this line. Deleting the file solved the issue
{ "source": "/(.*)", "destination": "/" }
{ "source": "/(.*)", "destination": "/" }
...
Jump to solution
5 Replies
Ping
Ping2mo ago
Can you show me the code which is making the calls?
Mark
MarkOP2mo ago
Sure, it's quite minimal. My auth/[...all] looks like this:
import { auth } from "@/lib/auth";
import { toNextJsHandler } from "better-auth/next-js";

export const { GET, POST } = toNextJsHandler(auth);
import { auth } from "@/lib/auth";
import { toNextJsHandler } from "better-auth/next-js";

export const { GET, POST } = toNextJsHandler(auth);
nikatune
nikatune2mo ago
all routes inside /api/auth/* or sign in route
Mark
MarkOP2mo ago
inside /api/auth
No description
Solution
Mark
Mark2mo ago
Oh nevermind, I had incorrectly configured vercel.json file with this line. Deleting the file solved the issue
{ "source": "/(.*)", "destination": "/" }
{ "source": "/(.*)", "destination": "/" }

Did you find this page helpful?