Skip to content

Commit 29660d9

Browse files
committed
Don't count users for options requests
1 parent f520e00 commit 29660d9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/middleware/userCounter.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import { getHash } from "../utils/getHash";
66
import { NextFunction, Request, Response } from "express";
77

88
export function userCounter(req: Request, res: Response, next: NextFunction): void {
9-
axios.post(`${config.userCounterURL}/api/v1/addIP?hashedIP=${getHash(getIP(req), 1)}`)
10-
.catch(() => Logger.debug(`Failing to connect to user counter at: ${config.userCounterURL}`));
9+
if (req.method !== "OPTIONS") {
10+
axios.post(`${config.userCounterURL}/api/v1/addIP?hashedIP=${getHash(getIP(req), 1)}`)
11+
.catch(() => Logger.debug(`Failing to connect to user counter at: ${config.userCounterURL}`));
12+
}
1113

1214
next();
1315
}

0 commit comments

Comments
 (0)