[GH-ISSUE #8015] enabledPaths option or typed disabledPaths for easier route restriction #10970

Open
opened 2026-04-13 07:21:37 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @ap-gun on GitHub (Feb 17, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/8015

Originally assigned to: @ping-maxwell on GitHub.

Is this suited for github?

  • Yes, this is suited for github

When I want to use only a small subset of auth routes (e.g. sign-in, sign-out, get-session), I find disabledPaths somewhat difficult to maintain. Since there's no type-level hint for valid paths, I need to manually look up every route and keep the list in sync across package updates.

A similar request was raised in #2622. I understand it was closed as NOT_PLANNED, but the maintainer later mentioned that enabledPaths "makes sense" and that more use cases had emerged — so I'd like to gently revisit this.

Describe the solution you'd like

Option A — enabledPaths (whitelist, preferred)

export const auth = betterAuth({
  enabledPaths: [
    '/sign-in/email',
    '/sign-out',
    '/get-session',
  ],
})

This way, only explicitly listed routes are exposed, which feels safer as a default.

Option B — Typed disabledPaths

export const auth = betterAuth({
  disabledPaths: [
    '/sign-up/email',
  ] satisfies AuthPath[], // autocomplete + compile-time check
})

Either option would make route restriction much easier to manage.

Describe alternatives you've considered

I noticed PR #3937 explored glob support, though it was eventually closed. Even with glob patterns, you'd still need to know route groupings in advance, so I think a whitelist approach would be more ergonomic for this use case.

Additional context

No response

Originally created by @ap-gun on GitHub (Feb 17, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/8015 Originally assigned to: @ping-maxwell on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. When I want to use only a small subset of auth routes (e.g. sign-in, sign-out, get-session), I find disabledPaths somewhat difficult to maintain. Since there's no type-level hint for valid paths, I need to manually look up every route and keep the list in sync across package updates. A similar request was raised in #2622. I understand it was closed as NOT_PLANNED, but the maintainer later mentioned that enabledPaths "makes sense" and that more use cases had emerged — so I'd like to gently revisit this. ### Describe the solution you'd like Option A — enabledPaths (whitelist, preferred) ```ts export const auth = betterAuth({ enabledPaths: [ '/sign-in/email', '/sign-out', '/get-session', ], }) ``` This way, only explicitly listed routes are exposed, which feels safer as a default. Option B — Typed disabledPaths ```ts export const auth = betterAuth({ disabledPaths: [ '/sign-up/email', ] satisfies AuthPath[], // autocomplete + compile-time check }) ``` Either option would make route restriction much easier to manage. ### Describe alternatives you've considered I noticed PR #3937 explored glob support, though it was eventually closed. Even with glob patterns, you'd still need to know route groupings in advance, so I think a whitelist approach would be more ergonomic for this use case. ### Additional context _No response_
GiteaMirror added the enhancementcore labels 2026-04-13 07:21:37 -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#10970