From 26771e2e7125adeedec53a887552cc8b9491416e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20M=C3=B3ricz?= Date: Tue, 1 Oct 2024 22:13:28 +0200 Subject: [PATCH] debug(zod): log unsupported protocol errors --- apps/api/src/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index 7d8817af..cf905207 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -192,6 +192,10 @@ if (cluster.isMaster) { app.use((err: unknown, req: Request<{}, ErrorResponse, undefined>, res: Response, next: NextFunction) => { if (err instanceof ZodError) { + if (Array.isArray(err.errors) && err.errors.find(x => x.message === "URL uses unsupported protocol")) { + Logger.warn("Unsupported protocol error: " + JSON.stringify(req.body)); + } + res.status(400).json({ success: false, error: "Bad Request", details: err.errors }); } else { next(err);