Skip to content

Commit cf59025

Browse files
authored
use x-forwarded-for instead of ip in rate limit incr tag (github#25585)
1 parent b3542e8 commit cf59025

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

middleware/rate-limit.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export default rateLimit({
1616
max: 100,
1717

1818
handler: (request, response, next, options) => {
19-
const tags = [`url:${request.url}`, `ip:${request.ip}`]
19+
const ip = request.headers['x-forwarded-for'] || request.ip
20+
const tags = [`url:${request.url}`, `ip:${ip}`]
2021
statsd.increment('rate_limit', 1, tags)
2122
// NOTE! At the time of writing, the actual rate limiting is disabled!
2223
// At least we can start recording how often this happens in Datadog.

0 commit comments

Comments
 (0)