[PR #6039] [MERGED] fix(oauth-proxy): return multiple Set-Cookie headers instead of a single comma-separated header #14647

Closed
opened 2026-04-13 09:33:48 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6039
Author: @nakasyou
Created: 11/17/2025
Status: Merged
Merged: 11/17/2025
Merged by: @Bekacru

Base: canaryHead: fix/multi-cookies-proxy


📝 Commits (1)

  • 75236cf fix(oauth-proxy): multiple cookie handling

📊 Changes

2 files changed (+96 additions, -6 deletions)

View changed files

📝 packages/better-auth/src/plugins/oauth-proxy/index.ts (+46 -5)
📝 packages/better-auth/src/plugins/oauth-proxy/oauth-proxy.test.ts (+50 -1)

📄 Description

According to RFC 6265, multiple Set-Cookie requests must be sent to create multiple cookies. In the current implementation, oAuthProxy uses comma-separated cookies. This doesn't work well.
image

I have fixed this in this PR.


Summary by cubic

Fix OAuth proxy cookie handling to send separate Set-Cookie headers per cookie per RFC 6265, so multi-cookie flows work reliably across browsers.

  • Bug Fixes
    • Use ctx.setCookie for each cookie instead of a single comma-separated Set-Cookie header.
    • Parse cookie attributes into CookieOptions (path, expires, samesite, httponly, max-age, prefix, partitioned).
    • Added a test to verify multiple cookies are set and redirect behavior works.

Written for commit 75236cf10f. Summary will update automatically on new commits.


🔄 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/6039 **Author:** [@nakasyou](https://github.com/nakasyou) **Created:** 11/17/2025 **Status:** ✅ Merged **Merged:** 11/17/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/multi-cookies-proxy` --- ### 📝 Commits (1) - [`75236cf`](https://github.com/better-auth/better-auth/commit/75236cf10f62198c442a36efc5b5b60a75c01c00) fix(oauth-proxy): multiple cookie handling ### 📊 Changes **2 files changed** (+96 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/oauth-proxy/index.ts` (+46 -5) 📝 `packages/better-auth/src/plugins/oauth-proxy/oauth-proxy.test.ts` (+50 -1) </details> ### 📄 Description According to [RFC 6265](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2), multiple Set-Cookie requests must be sent to create multiple cookies. In the current implementation, oAuthProxy uses comma-separated cookies. This doesn't work well. <img width="285" height="130" alt="image" src="https://github.com/user-attachments/assets/5bbfa3eb-1c40-4d01-8503-88db12f7210f" /> I have fixed this in this PR. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fix OAuth proxy cookie handling to send separate Set-Cookie headers per cookie per RFC 6265, so multi-cookie flows work reliably across browsers. - **Bug Fixes** - Use ctx.setCookie for each cookie instead of a single comma-separated Set-Cookie header. - Parse cookie attributes into CookieOptions (path, expires, samesite, httponly, max-age, prefix, partitioned). - Added a test to verify multiple cookies are set and redirect behavior works. <sup>Written for commit 75236cf10f62198c442a36efc5b5b60a75c01c00. Summary will update automatically on new commits.</sup> <!-- 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-04-13 09:33:48 -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#14647