Skip to content

Commit

Permalink
Update middlewares.js
Browse files Browse the repository at this point in the history
  • Loading branch information
PawanOsman authored Apr 1, 2023
1 parent d65a66a commit 3bbc53a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions middlewares.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function corsMiddleware(req, res, next) {
};

async function rateLimitMiddleware(req, res, next) {
let ip = req.headers["CF-Connecting-IP"] ?? req.headers["cf-connecting-ip"] ?? req.headers["X-Forwarded-For"] ?? req.headers["x-forwarded-for"] ?? req.src.ip;
let ip = req.headers["CF-Connecting-IP"] ?? req.headers["cf-connecting-ip"] ?? req.headers["X-Forwarded-For"] ?? req.headers["x-forwarded-for"] ?? req.ip;
if (WHITELISTED_IPS.includes(ip)) return next();
if (!rateLimit.has(ip)) {
rateLimit.set(ip, {
Expand Down Expand Up @@ -43,4 +43,4 @@ async function rateLimitMiddleware(req, res, next) {
next();
};

export { corsMiddleware, rateLimitMiddleware }
export { corsMiddleware, rateLimitMiddleware }

0 comments on commit 3bbc53a

Please sign in to comment.