cookies not set in Safari

Hey everyone,

I’m encountering an issue with Safari and cookies. My frontend is hosted at web.example.com and the backend API is at api.example.com. After signing in, the authentication cookie isn’t being stored in Safari. However, it works perfectly in Chrome and Firefox.

Interestingly, the cookie does get stored if I manually disable “Prevent cross-site tracking” in Safari’s settings, which suggests it’s related to cross-site behavior.

Here’s the current configuration I’m using with better-auth:

const auth = betterAuth({
    database: ...,
    advanced: {
      defaultCookieAttributes: {
        sameSite: "none",
        secure: true,
        httpOnly: true,
        ...(app.config.NODE_ENV === "production" ? { partitioned: true } : {}),
      },
    },
    emailAndPassword: {
      enabled: true,
    },
    trustedOrigins: [
      "http://localhost:5180",
      "https://web.example.com",
    ],


Any ideas on how to make it work without requiring users to change Safari settings manually?

Thanks in advance!
Was this page helpful?