refactor: keep existing rate limit behavior

This commit is contained in:
dreamhunter2333
2026-08-24 00:17:25 +08:00
parent 1cd43578ad
commit 7a09deb4a4
7 changed files with 9 additions and 144 deletions
+3 -5
View File
@@ -74,11 +74,9 @@ app.use('/*', async (c, next) => {
) {
const reqIp = c.req.raw.headers.get("cf-connecting-ip")
if (reqIp && c.env.RATE_LIMITER) {
const { success } = await c.env.RATE_LIMITER.limit({
key: `${c.req.path.startsWith("/user_api/address/")
? "/user_api/address/send_mail"
: c.req.path}|${reqIp}`
})
const { success } = await c.env.RATE_LIMITER.limit(
{ key: `${c.req.path}|${reqIp}` }
)
if (!success) {
return c.text(`IP=${reqIp} Rate limit exceeded for ${c.req.path}`, 429)
}