Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable server rate limit #1772

Merged
merged 2 commits into from Mar 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions packages/server/lib/controllers/ratelimit.middleware.ts
Expand Up @@ -7,7 +7,7 @@ import { getAccount, getRedisUrl, logger } from '@nangohq/shared';
const rateLimiter = await (async () => {
const opts = {
keyPrefix: 'middleware',
points: 1200,
points: parseInt(process.env['DEFAULT_RATE_LIMIT_PER_MIN'] || '0') || 2400,
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