Update rate-limit.mdx

This commit is contained in:
Shahriar
2025-03-25 00:22:32 +03:30
committed by GitHub
parent de5b8d2e5e
commit c3bd982029

View File

@@ -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
},
})
```