Skip to content

Commit

Permalink
Enable server rate limit
Browse files Browse the repository at this point in the history
  • Loading branch information
TBonnin committed Mar 1, 2024
1 parent d7cf723 commit 4d1f3d3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/server/lib/controllers/ratelimit.middleware.ts
Expand Up @@ -7,7 +7,7 @@ import { logger } from '@nangohq/shared';
const rateLimiter = await (async () => {
const opts = {
keyPrefix: 'middleware',
points: 1200,
points: parseInt(process.env['DEFAULT_RATE_LIMIT_PER_MIN'] || '0') || 1200,
duration: 60,
blockDuration: 0
};
Expand Down Expand Up @@ -44,9 +44,7 @@ export const rateLimiterMiddleware = (req: Request, res: Response, next: NextFun
res.setHeader('Retry-After', Math.floor(rateLimiterRes.msBeforeNext / 1000));
setXRateLimitHeaders(rateLimiterRes);
logger.info(`Rate limit exceeded for ${key}. Request: ${req.method} ${req.path})`);
next();
// TODO:
// res.status(429).send('Too Many Requests');
res.status(429).send('Too Many Requests');
});
};

Expand Down

0 comments on commit 4d1f3d3

Please sign in to comment.