BA
Better Auth•4mo ago
louis

getSession return null, but only when deployed

Hello, im building an application right now. frontend: sveltekit on cf worker backend: hono on cf worker On local development everything works as expected. When I deploy the apps to cloudflare and try get the session via authClient.getSession() i get null in return. On my local dev environment I get the session and user objects as expected. I checked cors but thats not the problem, because i recieve all the calls on the backend with code 200
14 Replies
louis
louisOP•4mo ago
The calls on the backend: POST https://app.mydomain.com/api/auth/sign-in/email - Ok @ 6/10/2025, 5:18:09 PM GET https://app.mydomain.com/api/auth/organization/list - Ok @ 6/10/2025, 5:18:12 PM GET https://app.mydomain.com/api/auth/organization/list - Ok @ 6/10/2025, 5:21:33 PM GET https://app.mydomain.com/api/auth/organization/list - Ok @ 6/10/2025, 5:21:52 PM GET https://app.mydomain.com/api/auth/organization/list - Ok @ 6/10/2025, 5:23:52 PM ok looks like getSession works in layout.ts but not layout.server.ts when i deploy it but locally it works?
rinshad
rinshad•3mo ago
i have same issue , only with social providers
telii_rumba
telii_rumba•3mo ago
have you tried with +page.ts or +page.server.ts instead ?
Kenny
Kenny•3mo ago
maybe not too useful, but worth a shot: Are all the correct env vars set?
sebastian
sebastian•3mo ago
Have checked cross sub domain cookies? or just cookies section in general?
rinshad
rinshad•3mo ago
i think the problem is with cookies, in production the cookies is not setting after the sign up
louis
louisOP•3mo ago
Got it working. I moved all into the sveltekit project now i can use auth.api
stormej
stormej•3mo ago
i also have the same problem with google sign in, cookies arent being set. did you find a solution for this @rinshad @louis
louis
louisOP•3mo ago
Whats ur stack? @stormej
stormej
stormej•3mo ago
nextjs on the frontend and hono bun backend useSession and getSession return run but only when i do it on prod
ahmadaccino
ahmadaccino•2mo ago
did you ever solve this?. facing the same thing, not sure what im doing wrong
stormej
stormej•2mo ago
No moved to making a flutter app, writing my own api calls and cookie management
iatomic.btc
iatomic.btc•2mo ago
What about you @ahmadaccino found a fix?
ahmadaccino
ahmadaccino•2mo ago
i migrated my app to clerk😭

Did you find this page helpful?