Skip to content

Commit e75689a

Browse files
authored
Merge pull request #15814 from github/repo-sync
repo sync
2 parents 90da848 + ddf3e90 commit e75689a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

middleware/rate-limit.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,18 @@ export default rateLimit({
1515
// (and not following the redirect to `/en`) at roughly 200k per minute.
1616
max: 100,
1717

18+
// Return rate limit info in the `RateLimit-*` headers
19+
standardHeaders: true,
20+
// Disable the `X-RateLimit-*` headers
21+
legacyHeaders: false,
22+
1823
handler: (request, response, next, options) => {
1924
const ip = request.headers['x-forwarded-for'] || request.ip
2025
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))
2230
// NOTE! At the time of writing, the actual rate limiting is disabled!
2331
// At least we can start recording how often this happens in Datadog.
2432
// The following line is commented out and replaced with `next()`

0 commit comments

Comments
 (0)