[PR #5342] [CLOSED] fix: incorrect context in auth endpoint #5942

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5342
Author: @himself65
Created: 10/15/2025
Status: Closed

Base: canaryHead: himself65/2025/10/15/fix


📝 Commits (1)

  • 796537e fix: incorrect context in auth endpoint

📊 Changes

2 files changed (+46 additions, -115 deletions)

View changed files

📝 packages/better-auth/src/api/to-auth-endpoints.ts (+42 -87)
📝 packages/core/src/api/index.ts (+4 -28)

📄 Description

Summary by cubic

Fixed context propagation in auth endpoints so handlers run with the correct runtime context and headers. Also simplified endpoint creation and aligned with the latest better-call API.

  • Bug Fixes

    • Run endpoints via wrap to ensure the original handler sees the correct context.
    • Write response headers to context.responseHeaders and append Set-Cookie correctly.
    • Proper error propagation: preserve APIError stack in debug, throw when not asResponse.
  • Refactors

    • Removed manual InternalContext plumbing; rely on runWithEndpointContext and endpoint.wrap.
    • Switched createAuthEndpoint to createEndpoint.create with default options middleware.
    • Updated better-call to ^1.0.21.

🔄 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/5342 **Author:** [@himself65](https://github.com/himself65) **Created:** 10/15/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `himself65/2025/10/15/fix` --- ### 📝 Commits (1) - [`796537e`](https://github.com/better-auth/better-auth/commit/796537e1ddc8320209e6f41d6f092e0f05a98b54) fix: incorrect context in auth endpoint ### 📊 Changes **2 files changed** (+46 additions, -115 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/to-auth-endpoints.ts` (+42 -87) 📝 `packages/core/src/api/index.ts` (+4 -28) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Fixed context propagation in auth endpoints so handlers run with the correct runtime context and headers. Also simplified endpoint creation and aligned with the latest better-call API. - **Bug Fixes** - Run endpoints via wrap to ensure the original handler sees the correct context. - Write response headers to context.responseHeaders and append Set-Cookie correctly. - Proper error propagation: preserve APIError stack in debug, throw when not asResponse. - **Refactors** - Removed manual InternalContext plumbing; rely on runWithEndpointContext and endpoint.wrap. - Switched createAuthEndpoint to createEndpoint.create with default options middleware. - Updated better-call to ^1.0.21. <!-- 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:42:07 -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#5942