[PR #4418] [CLOSED] docs: add cross domain cookies solution #5374

Closed
opened 2026-03-13 12:20:41 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4418
Author: @HenriqueBragaMoreira
Created: 9/4/2025
Status: Closed

Base: mainHead: main


📝 Commits (5)

📊 Changes

4 files changed (+289 additions, -11 deletions)

View changed files

📝 docs/content/docs/concepts/cookies.mdx (+71 -0)
📝 packages/better-auth/src/cookies/cookies.test.ts (+139 -0)
📝 packages/better-auth/src/cookies/index.ts (+55 -11)
📝 packages/better-auth/src/types/options.ts (+24 -0)

📄 Description

Summary by cubic

Add first-class cross-domain cookie support with a new crossOriginCookies option and stricter SameSite=None handling. Updates include docs, tests, and safer defaults to prevent misconfiguration.

  • New Features

    • Added advanced.crossOriginCookies with:
      • autoSecure: auto-sets Secure=true when SameSite=None
      • allowLocalhostUnsecure: allows non-secure cookies on localhost for dev
    • Enforces error when SameSite=None is used without Secure on non-localhost.
    • Applies secure cookie prefix (__Secure-) based on final merged attributes.
    • Supports partitioned cookies for cross-origin scenarios.
    • Expanded docs with a Cross-Domain Cookies guide, examples, and CSRF guidance.
  • Migration

    • If you use SameSite=None, ensure cookies are Secure on non-localhost:
      • Set secure: true, or
      • Enable advanced.crossOriginCookies.autoSecure (recommended), or
      • For local dev, set allowLocalhostUnsecure: true.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/4418 **Author:** [@HenriqueBragaMoreira](https://github.com/HenriqueBragaMoreira) **Created:** 9/4/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (5) - [`c1997e1`](https://github.com/better-auth/better-auth/commit/c1997e1fecc576148b96a4d48c8ceff983a12402) fix: cross-domain cookie - [`112bb6e`](https://github.com/better-auth/better-auth/commit/112bb6e32e8da3e1767fa44935d194f2a91685d4) Merge branch 'main' of https://github.com/better-auth/better-auth - [`fb83849`](https://github.com/better-auth/better-auth/commit/fb83849b88cd04082b3831426fb1344d6bd74e69) fix: unreachable code - [`13402ad`](https://github.com/better-auth/better-auth/commit/13402ad62435584130783c3b86135b0695833b66) fix: update trusted origin for cross-domain example - [`23f6f9a`](https://github.com/better-auth/better-auth/commit/23f6f9adbe144995f72b12d4fc3b6383804244b8) Merge branch 'main' into main ### 📊 Changes **4 files changed** (+289 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/concepts/cookies.mdx` (+71 -0) 📝 `packages/better-auth/src/cookies/cookies.test.ts` (+139 -0) 📝 `packages/better-auth/src/cookies/index.ts` (+55 -11) 📝 `packages/better-auth/src/types/options.ts` (+24 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Add first-class cross-domain cookie support with a new crossOriginCookies option and stricter SameSite=None handling. Updates include docs, tests, and safer defaults to prevent misconfiguration. - **New Features** - Added advanced.crossOriginCookies with: - autoSecure: auto-sets Secure=true when SameSite=None - allowLocalhostUnsecure: allows non-secure cookies on localhost for dev - Enforces error when SameSite=None is used without Secure on non-localhost. - Applies secure cookie prefix (__Secure-) based on final merged attributes. - Supports partitioned cookies for cross-origin scenarios. - Expanded docs with a Cross-Domain Cookies guide, examples, and CSRF guidance. - **Migration** - If you use SameSite=None, ensure cookies are Secure on non-localhost: - Set secure: true, or - Enable advanced.crossOriginCookies.autoSecure (recommended), or - For local dev, set allowLocalhostUnsecure: true. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:20:41 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#5374