fix RATE_LIMIT_BY=ip to use req.ip instead of a client-controlled header (#568)

This commit is contained in:
Aroh Maurya authored and GitHub committed 2026-10-11 14:06:24 -06:00
1 parent d657a0cb2d
commit b16a6f9e16
1 file changed
+2 -1
+2 -1
View File
@@ -144,7 +144,8 @@ const limiter = rateLimit({
const token = req.headers.authorization?.split(' ')[1] || '127.0.0.1';
return token;
case 'ip':
return req.headers['x-real-ip'];
// req.ip (not a raw header) so this respects trust proxy and cannot be spoofed by the client
return req.ip;
default:
return '127.0.0.1';
}