From 9bd3b83ef56ca643f77ac95ef7c247c6c9015f19 Mon Sep 17 00:00:00 2001 From: Asher Date: Thu, 8 May 2025 14:20:45 -0800 Subject: [PATCH] Fix port parseInt error handling parseInt returns NaN rather than throwing. --- src/node/routes/pathProxy.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/node/routes/pathProxy.ts b/src/node/routes/pathProxy.ts index 815da5aea..7d4f286f6 100644 --- a/src/node/routes/pathProxy.ts +++ b/src/node/routes/pathProxy.ts @@ -13,10 +13,8 @@ const getProxyTarget = ( ): string => { // If there is a base path, strip it out. const base = (req as any).base || "" - let port: number - try { - port = parseInt(req.params.port, 10) - } catch (err) { + const port = parseInt(req.params.port, 10) + if (isNaN(port)) { throw new HttpError("Invalid port", HttpCode.BadRequest) } return `http://0.0.0.0:${port}${opts?.proxyBasePath || ""}/${req.originalUrl.slice(base.length)}`