fastify / fastify-rate-limit

A low overhead rate limiter for your routes
MIT License
505 stars 72 forks source link

fix: `after` should show the same ttl as the rate limit headers #394

Closed gurgunday closed 1 week ago

gurgunday commented 1 week ago

Simplifies the rate limiter by only looking at the ttl to construct the after message — this aligns the message with the Retry-After header; before, it would just send the timeWindow, which is inaccurate

So even if a user had 5 seconds left, if the timeWindow was 50 seconds, the error would say, "Retry in 50 seconds" and not "Retry in 5 seconds"

gurgunday commented 1 week ago

I will rebase after https://github.com/fastify/fastify-rate-limit/pull/393 merges