cookie getting deleted automatically after refresh on signup with cloudfare workers
i have setup betterauth on cloudfare workers but my cookie is getting deleted after refresh on the client. i am using hono for the backend
20 Replies
could you share your auth config?
I am experiencing the same issue. Here is my auth.ts:
this is the auth config,also one question what should be the baseUrl in development i have put the development url that wrangler dev gives eg-http://127.0.0.1:8787
this is the auth config,also one question what should be the baseUrl in development i have put the development url that wrangler dev gives eg-http://127.0.0.1:8787/
@bekacru
@Rikki I'm facing redirect issue when i signup using github it redirect to the hono server from frontend i don't know how to fix this if you know can you help me out with this
i guess either you set the wrong callbackurl in github or either in setting up the authclient @techysiddhant
u sure your redirecturl looks like what mentioned in better auth docs ?

Cookie issue is probably related to subdomain issues if your client is different from your sever your cookie will not be passed
im not sure if the same issue, but I have my frontend hosted on vercel and my backend is hosted elsewhere. when signing in and looking at the cookies in the developer console. I see the session auth cookie appear and then immediately dissapear, backend sees the request and no errors but frontend is removing it for some reason?
Yeah it's definitely domain issue
They need to be either on the same domain or subdomain
I encountered this even with my infra being in the same platform
Is there documentation on this? Or the proper setup?
Yeah there is
Btw what domains are you using for your frontend and backend
Cookies | Better Auth
Learn how cookies are used in Better Auth.
Front end I am using vercel and backend is encore cloud for the moment
What's ur domains where you are hosting them
If it is a.com for frontned and b.com for backend your cookies will not transfer
yeah they have seperate domains
how can I setup to allow seperate domains I thought the whole point was CORS to allow this
You might want to put them on the same domain
Or look up cross domain sharing
It looks like it would be 100x more difficult if you did that
Stack Overflow
Share a cookie between two websites
I have built a website (A) which logs in to and retrieves customer data from a separate web service.
The organisation that owns (A) also has a website (B) which has a web form. They want a logged in
So after a bit of playing around I got this solved by setting up a proxy between my frontend and backend, the proxy was setup on NextJS backend and it looks something like this, it solves the cross domain sharing problem, and in the future if I setup under one domain its pretty easy to remove and work in place
according to me i think better auth does not supports the edge runtime
yep im was also witnessing the same problem
both parts are being locally hosted but backend was deployed on cloudflare worker
It supports edge runtime
Just have it on the same domain
It's cross subdomain cookies
U need your own custom domain
So it would be auth.domain.com and www.domain.com this configuration works
I tested it