[PR #7478] [MERGED] fix: include Set-Cookie when APIError thrown in hooks #15588

Closed
opened 2026-04-13 10:07:18 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7478
Author: @himself65
Created: 1/20/2026
Status: Merged
Merged: 1/20/2026
Merged by: @himself65

Base: canaryHead: himself65/2026/01/19/error-response


📝 Commits (1)

  • f568292 fix: include Set-Cookie when APIError thrown in hooks

📊 Changes

4 files changed (+52 additions, -14 deletions)

View changed files

📝 packages/better-auth/src/api/to-auth-endpoints.test.ts (+14 -0)
📝 packages/better-auth/src/api/to-auth-endpoints.ts (+9 -2)
📝 pnpm-lock.yaml (+28 -11)
📝 pnpm-workspace.yaml (+1 -1)

📄 Description

Fixes: https://github.com/better-auth/better-auth/issues/7473
Fixes: https://github.com/better-auth/better-auth/issues/4983


Summary by cubic

Preserves Set-Cookie headers when after hooks throw APIError, so clients still receive cookie updates on error responses. Adds a test to ensure the header is included.

  • Bug Fixes

    • Propagate Set-Cookie from APIError via better-call’s header symbol.
    • Add test verifying Set-Cookie is returned when an after hook throws.
  • Dependencies

    • Upgrade better-call to 1.2.0 to support header propagation.

Written for commit f5682929b0. Summary will update 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/7478 **Author:** [@himself65](https://github.com/himself65) **Created:** 1/20/2026 **Status:** ✅ Merged **Merged:** 1/20/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2026/01/19/error-response` --- ### 📝 Commits (1) - [`f568292`](https://github.com/better-auth/better-auth/commit/f5682929b0ad38306e78f5b16783eaebbf062ee2) fix: include `Set-Cookie` when APIError thrown in hooks ### 📊 Changes **4 files changed** (+52 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/to-auth-endpoints.test.ts` (+14 -0) 📝 `packages/better-auth/src/api/to-auth-endpoints.ts` (+9 -2) 📝 `pnpm-lock.yaml` (+28 -11) 📝 `pnpm-workspace.yaml` (+1 -1) </details> ### 📄 Description Fixes: https://github.com/better-auth/better-auth/issues/7473 Fixes: https://github.com/better-auth/better-auth/issues/4983 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Preserves Set-Cookie headers when after hooks throw APIError, so clients still receive cookie updates on error responses. Adds a test to ensure the header is included. - **Bug Fixes** - Propagate Set-Cookie from APIError via better-call’s header symbol. - Add test verifying Set-Cookie is returned when an after hook throws. - **Dependencies** - Upgrade better-call to 1.2.0 to support header propagation. <sup>Written for commit f5682929b0ad38306e78f5b16783eaebbf062ee2. Summary will update 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 10:07:18 -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#15588