Secure cookies not working in production

I'm using Nextjs 15 with React 19 and latest version of better-auth 1.1.4 My production is not using the secure better auth cookies and when i add the useSecureCookies: true in my auth config no cookies get stored and I'm not able to login. I'm using the Organization plugin, Magic Link plugin, nextCookies plugin, as well as session cookie cache enabled
POST /api/auth/sign-in/social?currentURL=http%3A%2F%2Flocalhost%3A3000%2F 200 in 184ms

GET /api/auth/callback/google?state=9NIV84IUrwYVuruWPEYWko_nwuqns93S&code=4%2F0AanRRrsTA_NhXjXVO5FJxZY8thG_rQjTJy1HSNNEJpTy8q6NMt3bWCxon2lGCtC8kIqZlQ&scope=email+profile+openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&authuser=0&prompt=none 302 in 1384ms

GET /api/auth/get-session 200 in 94ms

GET / 200 in 134ms
POST /api/auth/sign-in/social?currentURL=http%3A%2F%2Flocalhost%3A3000%2F 200 in 184ms

GET /api/auth/callback/google?state=9NIV84IUrwYVuruWPEYWko_nwuqns93S&code=4%2F0AanRRrsTA_NhXjXVO5FJxZY8thG_rQjTJy1HSNNEJpTy8q6NMt3bWCxon2lGCtC8kIqZlQ&scope=email+profile+openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&authuser=0&prompt=none 302 in 1384ms

GET /api/auth/get-session 200 in 94ms

GET / 200 in 134ms
1 Reply
bekacru
bekacru2mo ago
make sure to set BETTER_AUTH_URL set to the production url

Did you find this page helpful?