Skip to content

Commit

Permalink
use namespace for consistency (github#25615)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe authored Feb 24, 2022
1 parent 6bc2600 commit 43f0357
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion middleware/rate-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ export default rateLimit({
// (and not following the redirect to `/en`) at roughly 200k per minute.
max: 100,

// Return rate limit info in the `RateLimit-*` headers
standardHeaders: true,
// Disable the `X-RateLimit-*` headers
legacyHeaders: false,

handler: (request, response, next, options) => {
const ip = request.headers['x-forwarded-for'] || request.ip
const tags = [`url:${request.url}`, `ip:${ip}`]
statsd.increment('rate_limit', 1, tags)
statsd.increment('middleware.rate_limit', 1, tags)
// This is temporary until we fully understand fully that the
// rate limiter really is working in production.
response.setHeader('x-soft-rate-limit', JSON.stringify(options.store.hits))
// NOTE! At the time of writing, the actual rate limiting is disabled!
// At least we can start recording how often this happens in Datadog.
// The following line is commented out and replaced with `next()`
Expand Down

0 comments on commit 43f0357

Please sign in to comment.