[GH-ISSUE #395] Plugin onRequest: interrupting the request does not work #8252

Closed
opened 2026-04-13 03:20:27 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @0scrm on GitHub (Nov 2, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/395

Describe the bug
The documentation states that "To stop the request and send a response, return an object with a response property that contains a Response object.". However no matter what I tried the request does not get interrupted.

To Reproduce
Steps to reproduce the behavior:

  1. Create a basic plugin:
export const myPlugin = {
    id: "my-plugin",
    onRequest: async (request) => {
        return {
          response: new Response("Request interrupted", { status: 500 }),
        };
    },
}
  1. Add the plugin to your better-auth instance
export const auth = betterAuth({
  // ...
  plugins: [
    myPlugin(),
  ],
  // ...
})
  1. Run a better-auth instance
  2. See that the requests are not interrupted

Expected behavior
All requests should be interrupted (with the code snippet above)

Originally created by @0scrm on GitHub (Nov 2, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/395 **Describe the bug** The documentation states that "To stop the request and send a response, return an object with a response property that contains a Response object.". **However no matter what I tried the request does not get interrupted**. **To Reproduce** Steps to reproduce the behavior: 1. Create a basic plugin: ```ts export const myPlugin = { id: "my-plugin", onRequest: async (request) => { return { response: new Response("Request interrupted", { status: 500 }), }; }, } ``` 2. Add the plugin to your better-auth instance ```ts export const auth = betterAuth({ // ... plugins: [ myPlugin(), ], // ... }) ``` 3. Run a better-auth instance 5. See that the requests are not interrupted **Expected behavior** All requests should be interrupted (with the code snippet above)
GiteaMirror added the locked label 2026-04-13 03:20:27 -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#8252