Skip to content

better-auth default rateLimit config unusable with Cloudflare KV #41

@grrowl

Description

@grrowl

An annoying one for you. Cloudflare KV only supports KV TTLs >= 60s, but better-auth default rateLimit config now sets 10s as of better-auth/better-auth#4961

better-auth/better-auth#5452

You need to override the defaults or your app will crash all the time for auth routes:

{
    rateLimit: {
      enabled: true,
      window: 60, // Minimum KV TTL is 60s
      max: 100, // reqs/window
      customRules: {
        // https://github.com/better-auth/better-auth/issues/5452
        "*": {
          window: 60,
          max: 100,
        },
      },
    },
}

Should we consider adding Math.max(ttl, 60) and/or

console.warn(`[BetterAuthCloudflare] ttl ${ttl} is less than KV minimum of 60`)

to https://github.com/zpg6/better-auth-cloudflare/blob/3ff26670edbbd6d33597849d7c6a9ee4056f8086/src/index.ts#L113-L132 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions