File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -15,10 +15,18 @@ export default rateLimit({
15
15
// (and not following the redirect to `/en`) at roughly 200k per minute.
16
16
max : 100 ,
17
17
18
+ // Return rate limit info in the `RateLimit-*` headers
19
+ standardHeaders : true ,
20
+ // Disable the `X-RateLimit-*` headers
21
+ legacyHeaders : false ,
22
+
18
23
handler : ( request , response , next , options ) => {
19
24
const ip = request . headers [ 'x-forwarded-for' ] || request . ip
20
25
const tags = [ `url:${ request . url } ` , `ip:${ ip } ` ]
21
- statsd . increment ( 'rate_limit' , 1 , tags )
26
+ statsd . increment ( 'middleware.rate_limit' , 1 , tags )
27
+ // This is temporary until we fully understand fully that the
28
+ // rate limiter really is working in production.
29
+ response . setHeader ( 'x-soft-rate-limit' , JSON . stringify ( options . store . hits ) )
22
30
// NOTE! At the time of writing, the actual rate limiting is disabled!
23
31
// At least we can start recording how often this happens in Datadog.
24
32
// The following line is commented out and replaced with `next()`
You can’t perform that action at this time.
0 commit comments