From 8399a9c5379fe63a10c5ae8994613667c9563eaa Mon Sep 17 00:00:00 2001 From: Robbin Baauw Date: Mon, 20 May 2019 20:47:08 +0200 Subject: [PATCH] Dont log options requests --- cshub-server/src/utilities/LoggingMiddleware.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cshub-server/src/utilities/LoggingMiddleware.ts b/cshub-server/src/utilities/LoggingMiddleware.ts index b22bb2c0..be0e7b76 100644 --- a/cshub-server/src/utilities/LoggingMiddleware.ts +++ b/cshub-server/src/utilities/LoggingMiddleware.ts @@ -5,6 +5,9 @@ import logger from "./Logger"; export const logMiddleware = (req: Request, userObj: IJWTToken = null) => { - const userData = userObj !== null ? `, uid: ${userObj.user.id}` : ""; - logger.info(`[${req.headers["x-forwarded-for"] || req.connection.remoteAddress}${userData}] - ${req.path}`); + if (req.method !== "OPTIONS") { + const userData = userObj !== null ? `, uid: ${userObj.user.id}` : ""; + logger.info(`[${req.headers["x-forwarded-for"] || req.connection.remoteAddress}${userData}] - ${req.path}`); + } + };