From 3bbc53a22f2b9c2802a7ffde487e4f53b6c54c5d Mon Sep 17 00:00:00 2001 From: Pawan Osman Date: Sat, 1 Apr 2023 12:39:00 +0300 Subject: [PATCH] Update middlewares.js --- middlewares.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/middlewares.js b/middlewares.js index 2fbf207..d8d2e75 100644 --- a/middlewares.js +++ b/middlewares.js @@ -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, { @@ -43,4 +43,4 @@ async function rateLimitMiddleware(req, res, next) { next(); }; -export { corsMiddleware, rateLimitMiddleware } \ No newline at end of file +export { corsMiddleware, rateLimitMiddleware }