nextjs + external express api setup help, getting 403
Hi! 👋
I am getting invalid origin 403 from authClient methods like signIn and signUp.
I want to have Nextjs as frontend and express server separate as an API, including the better-auth routes
nextjs server runs on localhost:3000
so in here I put the localhost:5000 of the express server, because I am not using the same domain
express server runs on localhost:5000
and my env
BETTER_AUTH_URL=http://localhost:5000
, which is the default for baseURL for betterAuth config, it's the express server URL
am I doing everything correctly? now this ends up with 403 invalid origin when I use authClient methods from nextjs
but if I add/uncomment in the betterAuth config baseURL: 'http://localhost:3000'
the url of the frontend, which I probably shouldn't do?, but then everything works correctly...
help is appreciated
2 Replies