Skip to content

Commit

Permalink
Enable rate limiting (#25642)
Browse files Browse the repository at this point in the history
* Enable rate limiting

* higher limit specifically when running tests
  • Loading branch information
peterbe authored Feb 24, 2022
1 parent f48d536 commit 6a6dafa
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions middleware/rate-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default rateLimit({
// by the current number of instances.
// We have see DDoS attempts against prod that hits the `/` endpoint
// (and not following the redirect to `/en`) at roughly 200k per minute.
max: 100,
max: process.env.NODE_ENV === 'test' ? 1000 : 100,

// Return rate limit info in the `RateLimit-*` headers
standardHeaders: true,
Expand All @@ -23,10 +23,6 @@ export default rateLimit({
handler: (request, response, next, options) => {
const tags = [`url:${request.url}`, `ip:${request.ip}`]
statsd.increment('middleware.rate_limit', 1, tags)
// 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()`
// response.status(options.statusCode).send(options.message)
next()
response.status(options.statusCode).send(options.message)
},
})

0 comments on commit 6a6dafa

Please sign in to comment.