Felix
Felix
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
I've already tested that. That's not the problem. It seems more like the hook isn't sending the cookie when it's executed server-side. Although the token is included when I log the headers.
142 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
Hi, I was hoping, but unfortunately it still doesn't work for me this way. It works on the client side. It doesn't work on the server side. The cookie is present, session is null.
142 replies
BABetter Auth
Created by Manish on 4/20/2025 in #help
Cookies not saved in production
Are your backend and frontend using the same domain? Then configure cross-domain cookies https://www.better-auth.com/docs/concepts/cookies#cross-subdomain-cookies
4 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
Here is my summarized code
142 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
Unfortunately not. To this day, I'm still facing the same problem: the session can only be accessed client-side. I still haven't had any success with NextJS on the server-side 😦
142 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
fetchOptions: (await header()) => This doesn't work.
142 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
Hmm, I see your point about centrally fetching the session async in the layout. However, I also do a lot of fetching on the individual pages server-side, which is why I need async there anyway. Your suggestion is best practice, but it doesn't change my problem that the session is null. It doesn't really matter which call I make from the authclient, whether it's retrieving sessions, accounts, etc. everything that is serverside doesn't work with nextjs 😦
142 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
Unfortunately I don't have access to the internal API because I don't use NextJS as a backend, but only as a frontend. My backend is on express
142 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
HEADERS _ga=GA1.1.1653196102.1744302730; _ga_X5724CWZ7F=GS1.1.1744552980.4.1.1744556733.0.0.0; __Secure-playingg.session_token=xxx SESSION DATA null SESSION ERROR { status: 0, statusText: '' }
142 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
Makes sense, thanks. It actually works client-side now, thanks 🙂 It's strange that I've never encountered this issue with localhost before. I'm still having the same issue server-side, though. One more note: I'm also using the same backend with the Expo plugin. The session works there. It's probably a slightly different architecture, though.
142 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
Ahh, I see, so it doesn't work on both the server and client side with getSession/useSession. I have a /protected-client page where the session is also null in prod. I added it in Notion.
142 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
Mmm, you mean from my localhost to the prod API? The cookie is set on .playin.gg, so that wouldn't work.
142 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
142 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
Express Backend "better-auth": "^1.2.6", NextJS Frontend "better-auth": "^1.2.6", "next": "15.3.0", "react": "^19.1.0", Upgraded this morning hoping it would fix something, no change
142 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
No description
142 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
I had already tried this on your suggestion, unfortunately it didn't change anything
142 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
Mine is BETTER_AUTH_URL=https://api-ts.playin.gg Frontend: https://auth.playin.gg But @Fall don't seem to have exact the same problem
142 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
It's actually not even removed for me. I still have the cookie, but it's just not recognized.
142 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
Hmm, I'm also using NGINX as a reverse proxy. I was wondering if that could be the problem, but according to the logs, the cookies are present on the backend. I've already played around with the configuration a bit, but so far, I've never had any problems with cookies... but the better-auth session hooks in my deployed frontend still don't want to recognize the session, even though the cookie is present 😦 I still haven't found a solution.
142 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
Hmm, I tried that. It's also deployed in auth.playin.gg. But it still doesn't work. I don't understand it somehow
appName: "PlayinGG",
advanced: {
// cookiePrefix: "playingg",
crossSubDomainCookies: {
enabled: true,
domain: ".playin.gg",
},
/* defaultCookieAttributes: {
secure: true,
httpOnly: true,
sameSite: "none",
partitioned: true,
}, */
useSecureCookies: true,
},
appName: "PlayinGG",
advanced: {
// cookiePrefix: "playingg",
crossSubDomainCookies: {
enabled: true,
domain: ".playin.gg",
},
/* defaultCookieAttributes: {
secure: true,
httpOnly: true,
sameSite: "none",
partitioned: true,
}, */
useSecureCookies: true,
},
142 replies