disabledPaths accepting a glob pattern #1631

Closed
opened 2026-03-13 08:52:30 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @peterjarian on GitHub (Aug 3, 2025).

Is this suited for github?

  • Yes, this is suited for github

I am frustrated with the way better-auth handles enabling/disabling specific api routes.

Describe the solution you'd like

Currently, Better Auth requires you to mount its global router/handler in order to access its full functionality. If you don’t mount the router, you lose to features, as some things like callbacks are only available when you mount an api route. This makes it difficult to implement custom authentication flows or integrate authentication logic directly into your own API endpoints.

Additionally, while there is a disabledPaths configuration option, it is annoying to use because you have to explicitly specify every route you want to disable. This makes it hard to selectively override or customize specific auth routes, and increases the risk of missing a route or introducing inconsistencies in your authentication logic.

Describe alternatives you've considered

My proposed solution is to allow the disabledPaths configuration option to accept not just an array of strings, but also glob patterns. Currently, the code simply checks on each request if the path is included in disabledPaths. It would not be a significant change to support glob patterns—the internal logic can remain mostly the same—but this would allow developers to be much more precise about which routes they want to enable or disable. This added flexibility would make it easier to customize authentication flows and override specific routes as needed.

Additional context

A issue was already report about the same problem, but with a different solution: https://github.com/better-auth/better-auth/issues/2622

Originally created by @peterjarian on GitHub (Aug 3, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. I am frustrated with the way better-auth handles enabling/disabling specific api routes. ### Describe the solution you'd like Currently, Better Auth requires you to mount its global router/handler in order to access its full functionality. If you don’t mount the router, you lose to features, as some things like callbacks are only available when you mount an api route. This makes it difficult to implement custom authentication flows or integrate authentication logic directly into your own API endpoints. Additionally, while there is a disabledPaths configuration option, it is annoying to use because you have to explicitly specify every route you want to disable. This makes it hard to selectively override or customize specific auth routes, and increases the risk of missing a route or introducing inconsistencies in your authentication logic. ### Describe alternatives you've considered My proposed solution is to allow the disabledPaths configuration option to accept not just an array of strings, but also glob patterns. Currently, the code simply checks on each request if the path is included in disabledPaths. It would not be a significant change to support glob patterns—the internal logic can remain mostly the same—but this would allow developers to be much more precise about which routes they want to enable or disable. This added flexibility would make it easier to customize authentication flows and override specific routes as needed. ### Additional context A issue was already report about the same problem, but with a different solution: https://github.com/better-auth/better-auth/issues/2622
GiteaMirror added the enhancement label 2026-03-13 08:52:30 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Nov 2, 2025):

Hi, @peterjarian. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You proposed enhancing the disabledPaths option to accept glob patterns for more flexible route management.
  • This would simplify enabling or disabling multiple API routes selectively.
  • The change aims to improve custom authentication flows with minimal code adjustments.
  • No further comments or activity have occurred since your initial suggestion.

Next Steps:

  • Please let me know if this feature request is still relevant to the latest version of better-auth by commenting below.
  • If I don’t hear back within 7 days, this issue will be automatically closed.

Thanks for your understanding and contribution!

@dosubot[bot] commented on GitHub (Nov 2, 2025): Hi, @peterjarian. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You proposed enhancing the `disabledPaths` option to accept glob patterns for more flexible route management. - This would simplify enabling or disabling multiple API routes selectively. - The change aims to improve custom authentication flows with minimal code adjustments. - No further comments or activity have occurred since your initial suggestion. **Next Steps:** - Please let me know if this feature request is still relevant to the latest version of better-auth by commenting below. - If I don’t hear back within 7 days, this issue will be automatically closed. Thanks for your understanding and contribution!
Author
Owner

@lukaslumiere commented on GitHub (Dec 24, 2025):

+1

@lukaslumiere commented on GitHub (Dec 24, 2025): +1
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1631