[GH-ISSUE #774] To disable client side sendVerificationEmail + More visibility controls around exposed APIs #25747

Closed
opened 2026-04-17 16:01:04 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @arfath-linklet on GitHub (Dec 5, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/774

An extension of issue https://github.com/better-auth/better-auth/issues/708.

Apologies: This is both a bug report and feature request.

All APIs exposed need more guards or general ways of disabling. Issue 708 above speaks about disabling deleteUser from client. This specific use-case was resolved with merged PR. API can be disabled with config now.

const config = {
  user: {
    deleteUser: {
      enabled: false,
    },
  }
}

But a general way to disable some exposed APIs would be necessary. For instance sendVerificationEmail may trigger emails to any registered user. This can lead to spammy verification emails to any user from any user.

Workaround: As specified by @Bekacru , APIs can be disabled by config where possible or via the API handler manually

const FORBIDDEN_PATHS = [
  "/api/auth/delete-user",
  "/api/auth/send-verification-email",
  // others...
];

export const APIRoute = createAPIFileRoute("/api/auth/$")({
  GET: ({ request }) => auth.handler(request),
  POST: ({ request }) => {
    const url = new URL(request.url);

    if (FORBIDDEN_PATHS.includes(url.pathname)) {
      return new Response("Forbidden", {
        status: 403,
      });
    }

    return auth.handler(request);
  },
});

Requesting:

  1. All APIs could be disabled by default and opt-in enabled in a generic way.
  2. Better docs and visibility on all APIs that are exposed to client.
Originally created by @arfath-linklet on GitHub (Dec 5, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/774 An extension of issue https://github.com/better-auth/better-auth/issues/708. Apologies: This is both a bug report and feature request. All APIs exposed need more guards or general ways of disabling. Issue 708 above speaks about disabling deleteUser from client. This specific use-case was resolved with merged PR. API can be disabled with config now. ``` const config = { user: { deleteUser: { enabled: false, }, } } ``` But a general way to disable some exposed APIs would be necessary. For instance `sendVerificationEmail` may trigger emails to any registered user. This can lead to spammy verification emails to any user from any user. Workaround: As specified by @Bekacru , APIs can be disabled by config where possible or via the API handler manually ``` const FORBIDDEN_PATHS = [ "/api/auth/delete-user", "/api/auth/send-verification-email", // others... ]; export const APIRoute = createAPIFileRoute("/api/auth/$")({ GET: ({ request }) => auth.handler(request), POST: ({ request }) => { const url = new URL(request.url); if (FORBIDDEN_PATHS.includes(url.pathname)) { return new Response("Forbidden", { status: 403, }); } return auth.handler(request); }, }); ``` Requesting: 1. All APIs could be disabled by default and opt-in enabled in a generic way. 2. Better docs and visibility on all APIs that are exposed to client.
GiteaMirror added the locked label 2026-04-17 16:01:04 -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#25747