betterauth/react acting weird and hono cors problem
So I saw another post with hono and react but I still get the CORS problem. Tried everything I saw.
Context: I'm running everything from an ubuntu server on my lan, 192.168.18.163. Backend is on hono port 3000 and frontend with vite and 5173. As both are there, on my code I write localhost because they are on the same location.
I added all cors stuff I saw, proxy redirect from vite, even both ports just to see if that's the problem. And I still get cors problems. but the client seems to be acting weird (?) with the request because I can see the origin with my server ip, but should be localhost? here's the raw request:
And here u can see that I (should) have correctly added cors management (added both ports just in case idk), one screenshot is from server and the other from client and vite client conf:



4 Replies
also other requests with tanstack query are working. It's only when better-auth does the request
does requests to better auth routes using tanstack query working? like sign-in
still the same
@varo your issue is probably the
origin
array in your first image
For example, you have a single string:
when it should be separate strings (not stuck together in the same quote):
Also, there's no reason to specify the backend in trustedOrigin
, so really you should just use
Cors work fine for me, same setup with
- React frontend (vite, tanstack router)
- Hono backend (nodejs)
Full repo here for your reference: https://github.com/nktnet1/rt-stack