Trying standard next.js api route for auth (from docs) and getting #405 error [Bug?]

Is anyone else seeing this in development? Prior versions were working for me on email/password and github social provider. Next.js 15.3, Better 1.3.4, ubuntu 24.04, node 21.x
5 Replies
aseppp
aseppp3mo ago
may I please check the file and it's directory path?
Vince Fulco
Vince FulcoOP3mo ago
here is the file
import { toNextJsHandler } from 'better-auth/next-js';
import { auth } from '@/lib/auth/auth';

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

export const { GET, POST } = toNextJsHandler(auth.handler);
and the route is src/app/api/auth/[...all]/route.ts. i've got the auth file one level down (from the documented code) in a folder to organize all the auth files
aseppp
aseppp3mo ago
on what page or action did you get the error #405?
Vince Fulco
Vince FulcoOP3mo ago
[SOLVED: ] Not sure why this is working for others " export const { GET, POST } = toNextJsHandler(auth);" Claude Sonnet raised the Next.js 15.4.3 bug when combining methods. Modifying this way fixed it
import { auth } from '@/lib/auth/auth';
import { toNextJsHandler } from 'better-auth/next-js';

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

const handlers = toNextJsHandler(auth);
export const GET = handlers.GET;
export const POST = handlers.POST;
i spoke too soon, this error popped up again. i had to set all specific api routes. i think there is an issue with next 15.4, drizzle, and better-auth butcan't get to the bottom of it.
insightautomate
Did you ever manage to get to the bottom of this? I'm having similar issues

Did you find this page helpful?