[PR #5529] [CLOSED] fix: auth endpoint wrapper might not have ctx #14311

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

📋 Pull Request Information

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

Base: canaryHead: himself65/2025/10/23/handler


📝 Commits (3)

📊 Changes

2 files changed (+106 additions, -108 deletions)

View changed files

📝 packages/better-auth/src/api/to-auth-endpoints.ts (+99 -107)
📝 packages/core/src/api/index.ts (+7 -1)

📄 Description

Summary by cubic

Fix the auth endpoint wrapper so ctx is always present. Endpoints are now created with createEndpoint and call the original handler via a handler getter, keeping hooks and error handling intact.

  • Bug Fixes

    • Ensure ctx is passed to auth endpoints and before/after hooks.
    • Prevent undefined ctx when calling wrapped endpoints.
  • Refactors

    • toAuthEndpoints now uses createEndpoint and invokes endpoint.handler instead of the endpoint function.
    • createAuthEndpoint exposes the original handler via a handler getter and returns the createEndpoint result.

🔄 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/5529 **Author:** [@himself65](https://github.com/himself65) **Created:** 10/23/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `himself65/2025/10/23/handler` --- ### 📝 Commits (3) - [`ba94a53`](https://github.com/better-auth/better-auth/commit/ba94a534852ceaf0875695b4be21819384e1bf44) fix: auth endpoint wrapper might not have ctx - [`c34fd5b`](https://github.com/better-auth/better-auth/commit/c34fd5b3191c96d7b7e4fec05315ca34256ef067) fix: test - [`549edfb`](https://github.com/better-auth/better-auth/commit/549edfb122a50d643bce8f5337eea907933868fe) chore: handler ### 📊 Changes **2 files changed** (+106 additions, -108 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/to-auth-endpoints.ts` (+99 -107) 📝 `packages/core/src/api/index.ts` (+7 -1) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Fix the auth endpoint wrapper so ctx is always present. Endpoints are now created with createEndpoint and call the original handler via a handler getter, keeping hooks and error handling intact. - **Bug Fixes** - Ensure ctx is passed to auth endpoints and before/after hooks. - Prevent undefined ctx when calling wrapped endpoints. - **Refactors** - toAuthEndpoints now uses createEndpoint and invokes endpoint.handler instead of the endpoint function. - createAuthEndpoint exposes the original handler via a handler getter and returns the createEndpoint result. <!-- 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:24:36 -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#14311