[GH-ISSUE #2177] Type error in middlware example on plugins under concepts page #26407

Closed
opened 2026-04-17 16:57:44 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @shahreazebd on GitHub (Apr 8, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/2177

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

doc -> concepts -> plugins -> middleware

const myPlugin = ()=>{
    return {
        id: "my-plugin",
        middleware: [
            {
                path: "/my-plugin/hello-world",
                middleware: createAuthMiddleware(async(ctx)=>{
                    //do something
                })
            }
        ]
    } satisfies BetterAuthPlugin
}

The array key name will be middlewares. The middleware type is Endpoint. So it give type error.

Current vs. Expected behavior

The array key name will be middlewares. The middleware type is Endpoint. So it give type error.

What version of Better Auth are you using?

1.2.x

Provide environment information

- Os Mac Mini
- Browser Chrome

Which area(s) are affected? (Select all that apply)

Backend, Types

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

No response

Originally created by @shahreazebd on GitHub (Apr 8, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/2177 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce doc -> concepts -> plugins -> middleware ```ts const myPlugin = ()=>{ return { id: "my-plugin", middleware: [ { path: "/my-plugin/hello-world", middleware: createAuthMiddleware(async(ctx)=>{ //do something }) } ] } satisfies BetterAuthPlugin } ``` The array key name will be middlewares. The middleware type is Endpoint. So it give type error. ### Current vs. Expected behavior The array key name will be middlewares. The middleware type is Endpoint. So it give type error. ### What version of Better Auth are you using? 1.2.x ### Provide environment information ```bash - Os Mac Mini - Browser Chrome ``` ### Which area(s) are affected? (Select all that apply) Backend, Types ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-17 16:57:44 -05:00
Author
Owner

@Kinfe123 commented on GitHub (Apr 8, 2025):

closed - #2058

<!-- gh-comment-id:2787218520 --> @Kinfe123 commented on GitHub (Apr 8, 2025): closed - #2058
Author
Owner

@shahreazebd commented on GitHub (Apr 9, 2025):

Check these images. The type error still exists.

https://ibb.co.com/HpnyL7nY
https://ibb.co.com/gLb2wB3W

<!-- gh-comment-id:2788371593 --> @shahreazebd commented on GitHub (Apr 9, 2025): Check these images. The type error still exists. https://ibb.co.com/HpnyL7nY https://ibb.co.com/gLb2wB3W
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#26407