[PR #7070] [MERGED] fix(api): chain plugin onRequest hooks properly #15303

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7070
Author: @bytaesu
Created: 12/31/2025
Status: ✅ Merged
Merged: 12/31/2025
Merged by: @himself65

Base: canary ← Head: 2025-12-31/fix/plugin-onrequest-chain-behavior


📝 Commits (1)

  • 04d6482 fix: chain plugin onRequest hooks properly

📊 Changes

2 files changed (+139 additions, -10 deletions)

View changed files

📝 packages/better-auth/src/api/index.test.ts (+128 -0)
📝 packages/better-auth/src/api/index.ts (+11 -10)

📄 Description

Currently, only the first plugin that returned a modified request would execute, preventing subsequent plugins from processing the request.

  • All plugins now execute sequentially, passing the modified request
    along the chain, unless a response is returned (which stops the chain)
  • Rate limiting is now applied after all plugin hooks execute, ensuring
    it checks the final modified request.

Summary by cubic

Chained plugin onRequest hooks so all plugins run in order and can modify the request. Rate limiting now checks the final request after all hooks.

  • Bug Fixes
    • Run all onRequest hooks sequentially, passing the modified request.
    • Stop the chain when a plugin returns a response.
    • Apply rate limiting after hooks, using the final request.

Written for commit 04d64822b3. 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/7070 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 12/31/2025 **Status:** ✅ Merged **Merged:** 12/31/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2025-12-31/fix/plugin-onrequest-chain-behavior` --- ### 📝 Commits (1) - [`04d6482`](https://github.com/better-auth/better-auth/commit/04d64822b317a30c50d7cbf00a8e695ee68e58af) fix: chain plugin onRequest hooks properly ### 📊 Changes **2 files changed** (+139 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/index.test.ts` (+128 -0) 📝 `packages/better-auth/src/api/index.ts` (+11 -10) </details> ### 📄 Description Currently, only the first plugin that returned a modified request would execute, preventing subsequent plugins from processing the request. - All plugins now execute sequentially, passing the modified request along the chain, unless a response is returned (which stops the chain) - Rate limiting is now applied after all plugin hooks execute, ensuring it checks the final modified request. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Chained plugin onRequest hooks so all plugins run in order and can modify the request. Rate limiting now checks the final request after all hooks. - **Bug Fixes** - Run all onRequest hooks sequentially, passing the modified request. - Stop the chain when a plugin returns a response. - Apply rate limiting after hooks, using the final request. <sup>Written for commit 04d64822b317a30c50d7cbf00a8e695ee68e58af. 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 09:57:14 -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#15303