From c3bd98202964dc4cb8637dee969e239551a27ec6 Mon Sep 17 00:00:00 2001 From: Shahriar <31452340+ShahriarKh@users.noreply.github.com> Date: Tue, 25 Mar 2025 00:22:32 +0330 Subject: [PATCH] Update rate-limit.mdx --- docs/content/docs/concepts/rate-limit.mdx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/content/docs/concepts/rate-limit.mdx b/docs/content/docs/concepts/rate-limit.mdx index 18bd337424..9daf768790 100644 --- a/docs/content/docs/concepts/rate-limit.mdx +++ b/docs/content/docs/concepts/rate-limit.mdx @@ -15,13 +15,23 @@ import { betterAuth } from "better-auth"; export const auth = betterAuth({ rateLimit: { - enabled: true, window: 10, // time window in seconds max: 100, // max requests in the window }, }) ``` +Rate limiting is disabled in development mode by default. In order to enable it, set `enabled` to `true`: + +```ts title="auth.ts" +export const auth = betterAuth({ + rateLimit: { + enabled: true, + //...other options + }, +}) +``` + In addition to the default settings, Better Auth provides custom rules for specific paths. For example: - `/sign-in/email`: Is limited to 3 requests within 10 seconds. @@ -40,7 +50,6 @@ import { betterAuth } from "better-auth"; export const auth = betterAuth({ //...other options rateLimit: { - enabled: true, window: 60, // time window in seconds max: 100, // max requests in the window }, @@ -55,7 +64,6 @@ import { betterAuth } from "better-auth"; export const auth = betterAuth({ //...other options rateLimit: { - enabled: true, window: 60, // time window in seconds max: 100, // max requests in the window customRules: { @@ -89,7 +97,6 @@ export const auth = betterAuth({ rateLimit: { storage: "database", modelName: "rateLimit", //optional by default "rateLimit" is used - enabled: true }, }) ```