Skip to content

Commit 8e97af5

Browse files
authored
fix: don't apply rate limit to health check endpoints (#583)
* fix: don't apply rate limit to health check endpoints * remove health check
1 parent 3f0b01d commit 8e97af5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/server/middleware/rateLimit.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { createCustomError } from "./error";
66

77
export const withRateLimit = async (server: FastifyInstance) => {
88
server.addHook("onRequest", async (request, reply) => {
9+
if (request.url === "/" || request.url === "/json") {
10+
return;
11+
}
12+
913
const epochTimeInMinutes = Math.floor(new Date().getTime() / (1000 * 60));
1014
const key = `rate-limit:global:${epochTimeInMinutes}`;
1115
const count = await redis.incr(key);

0 commit comments

Comments
 (0)