[PR #5806] feat: add support for custom response status codes #14485

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

Original Pull Request: https://github.com/better-auth/better-auth/pull/5806

State: closed
Merged: Yes


What is changing?
Updates better-auth to expose the same functionality as in https://github.com/Bekacru/better-call/pull/69 (custom response status codes via ctx.setStatus()).


Summary by cubic

Adds custom response status code support in better-auth via ctx.setStatus. Endpoints can now return a Response with the chosen status or include the status alongside the payload.

  • New Features

    • Added returnStatus option to toAuthEndpoints to include status with response and headers.
    • asResponse now respects custom status when building a Response.
    • Propagates status from thrown Response-like errors via statusCode and headers.
    • Tests cover both asResponse and returnStatus flows with a 201 status.
  • Migration

    • No changes required. Use c.setStatus(...) and opt in with { asResponse: true } or { returnStatus: true }.
    • Defaults remain unchanged; session route sets returnStatus to false.

Written for commit f5a925d824. Summary will update automatically on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/5806 **State:** closed **Merged:** Yes --- **What is changing?** Updates `better-auth` to expose the same functionality as in https://github.com/Bekacru/better-call/pull/69 (custom response status codes via `ctx.setStatus()`). <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds custom response status code support in better-auth via ctx.setStatus. Endpoints can now return a Response with the chosen status or include the status alongside the payload. - **New Features** - Added returnStatus option to toAuthEndpoints to include status with response and headers. - asResponse now respects custom status when building a Response. - Propagates status from thrown Response-like errors via statusCode and headers. - Tests cover both asResponse and returnStatus flows with a 201 status. - **Migration** - No changes required. Use c.setStatus(...) and opt in with { asResponse: true } or { returnStatus: true }. - Defaults remain unchanged; session route sets returnStatus to false. <sup>Written for commit f5a925d8246646568497b562c0ca1e8fc592ce03. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 09:29:55 -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#14485