rate-limit Rate Limiting
Per-key limits on the edge โ source on GitHub ๐ Share
src/index.ts
import { Hono } from 'hono'
const app = new Hono<{ Bindings: Env }>()
app.get('/', async (c) => {
const key = c.req.header('cf-connecting-ip') ?? 'anonymous'
const { success } = await c.env.RATE_LIMITER.limit({ key })
if (!success) {
return c.text('Too Many Requests', 429)
}
return c.text('OK')
})
export default app
Try it โ requests go to a Dynamic Worker running this code. State is isolated per browser session and expires after a while.![response]()
response will appear here