Skip to content

Commit c3b1536

Browse files
committed
fix: make rateLimiter IPv6 compatible using ipKeyGenerator
1 parent 83fb686 commit c3b1536

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Request } from "express";
2-
import { rateLimit } from "express-rate-limit";
2+
import { ipKeyGenerator, rateLimit } from "express-rate-limit";
33

44
import { env } from "@/common/utils/envConfig";
55

@@ -9,7 +9,7 @@ const rateLimiter = rateLimit({
99
message: "Too many requests, please try again later.",
1010
standardHeaders: true,
1111
windowMs: 15 * 60 * env.COMMON_RATE_LIMIT_WINDOW_MS,
12-
keyGenerator: (req: Request) => req.ip as string,
12+
keyGenerator: (req: Request) => ipKeyGenerator(req.ip as string), // IPv6 Compatible
1313
});
1414

1515
export default rateLimiter;

0 commit comments

Comments
 (0)