You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It doesn't work, because RedisStore reads the windowMs property when initializing, and uses it to set reset-timer. Without it, the reset-timer is set by default to 24 hours. Additionally, in the above example the RedisStore would always use the same key prefix, which means that different API routes would count towards the same limit.
So in short, you always need to create a new RedisStore with each limiter.
Description
This not an bug, but just an issue I faced, which will hopefully save somebody hours of work.
For most this is probably already obvious, but you need to create a new
RedisStore
for each limiter.You cannot define a
RedisStore
and then re-use it accross all limiters. This does NOT work:It doesn't work, because
RedisStore
reads thewindowMs
property when initializing, and uses it to setreset-timer
. Without it, thereset-timer
is set by default to 24 hours. Additionally, in the above example theRedisStore
would always use the same keyprefix
, which means that different API routes would count towards the same limit.So in short, you always need to create a new
RedisStore
with each limiter.EXTRA
You can extract the
sendCommand
function to re-use it across all newRedisStores
.The text was updated successfully, but these errors were encountered: