BetterAuth with custom Nextjs basePath

Hi everyone! I'm working on a project that's hosted on a subdomain of a website, so I had to set a custom basePath in my Next.js configuration. Now I'm having trouble getting BetterAuth to work properly with this setup. I adjusted the basePath for the authClient, and the best result I got was a POST request being sent to:
http://localhost:3000/custom_path/api/auth/sign-up/email
http://localhost:3000/custom_path/api/auth/sign-up/email
However, in the console, I get the following error:
ERROR [Better Auth]: Error [Error: NOT_FOUND]
POST /api/auth/sign-up/email 404 in 209ms
ERROR [Better Auth]: Error [Error: NOT_FOUND]
POST /api/auth/sign-up/email 404 in 209ms
I’ve already updated the BETTER_AUTH_URL to http://localhost:3000/custom_path, but then the POST request was sent to:
http://localhost:3000/custom_path/sign-up/email
http://localhost:3000/custom_path/sign-up/email
And in the console, it only showed sign-up/email. Now I’m passing the full path to the client, using:
baseURL: "http://localhost:3000/custom_path/api/auth"
baseURL: "http://localhost:3000/custom_path/api/auth"
This looks correct in the network tab and seems to be received correctly, but I’m still getting the same NOT_FOUND error. Any ideas on what I might be missing? Thanks in advance!
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?