Fall
BABetter Auth
•Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
yes
117 replies
BABetter Auth
•Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
localhost works fine
117 replies
BABetter Auth
•Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
just prod
117 replies
BABetter Auth
•Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
but the problem continue here
117 replies
BABetter Auth
•Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
same, my frontend is osler.app and backend is api.osler.app
117 replies
BABetter Auth
•Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
@daanish like this?
advanced: {
crossSubDomainCookies: {
enabled: true,
domain: '.osler.app',
},
useSecureCookies: true,
}
117 replies
BABetter Auth
•Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
i'm using: "better-auth": "^1.2.5",
117 replies
BABetter Auth
•Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
The cookie clearing during the get-session call continues, and the baseURL mismatch wasn’t the problem. It’s the same issue as @daanish
117 replies
BABetter Auth
•Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
I miss type safety right now
117 replies
BABetter Auth
•Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
oh 😳
117 replies
BABetter Auth
•Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
import { betterAuth } from 'better-auth';
import { drizzleAdapter } from 'better-auth/adapters/drizzle';
import * as schema from '@/db/schema';
import { db } from '@/db'; import { env } from '@/env'; export const auth = betterAuth({ secret: env.BETTER_AUTH_SECRET, baseUrl: env.BETTER_AUTH_URL, database: drizzleAdapter(db, { provider: 'pg', schema: schema, }), user: { modelName: 'doctor', }, account: { fields: { userId: 'doctorId', } }, session: { fields: { userId: 'doctorId', }, storeSessionInDatabase: true, }, emailAndPassword: { enabled: true, async sendResetPassword(data, request) { console.log(data, request); }, }, advanced: { crossSubDomainCookies: { enabled: true, domain: '.osler.app', }, useSecureCookies: true, }, appName: 'Osler', trustedOrigins: ['http://localhost:3001', 'https://osler.app'], socialProviders: { google: { clientId: env.GOOGLE_CLIENT_ID, clientSecret: env.GOOGLE_CLIENT_SECRET, } } });
import { db } from '@/db'; import { env } from '@/env'; export const auth = betterAuth({ secret: env.BETTER_AUTH_SECRET, baseUrl: env.BETTER_AUTH_URL, database: drizzleAdapter(db, { provider: 'pg', schema: schema, }), user: { modelName: 'doctor', }, account: { fields: { userId: 'doctorId', } }, session: { fields: { userId: 'doctorId', }, storeSessionInDatabase: true, }, emailAndPassword: { enabled: true, async sendResetPassword(data, request) { console.log(data, request); }, }, advanced: { crossSubDomainCookies: { enabled: true, domain: '.osler.app', }, useSecureCookies: true, }, appName: 'Osler', trustedOrigins: ['http://localhost:3001', 'https://osler.app'], socialProviders: { google: { clientId: env.GOOGLE_CLIENT_ID, clientSecret: env.GOOGLE_CLIENT_SECRET, } } });
117 replies
BABetter Auth
•Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
my API runs on a subdomain, api.osler, while my Next.js app runs on the base domain
117 replies
BABetter Auth
•Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
prod
117 replies
BABetter Auth
•Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
yes, the request does send a valid cookie. I suspect the issue might be related to the session database schema
117 replies
BABetter Auth
•Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment

117 replies
BABetter Auth
•Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
Same issue, the cookie is set when sign-in but get-session call remove it
117 replies