Skip to content

Commit

Permalink
Setter rate limit per auth token med ip som fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
maccyber committed Feb 18, 2025
1 parent 261ab7b commit 567826a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const apiRateLimit = rateLimit({
message: 'You have exceeded the 100 requests in 1s limit!',
standardHeaders: true,
legacyHeaders: false,
keyGenerator: (req) => req.headers?.authorization?.replace('Bearer', '') || req.ip,
keyGenerator: (req) => req.headers?.authorization?.replace('Bearer ', '') || req.ip,
handler: (req, res, next, options) => {
if (req.rateLimit.remaining === 0) {
log.error(`Rate limit reached for client ${req.ip}`);
Expand Down

0 comments on commit 567826a

Please sign in to comment.