From eb324747cc7b6196f07a349335d7c65003ad8ce1 Mon Sep 17 00:00:00 2001 From: Hai Nguyen Hong Date: Sat, 27 Apr 2024 16:36:47 +0700 Subject: [PATCH] Fix bug cannot proxy to HTTP server with port other than 80 urlParts.host return 'host:port' which causes 'Error: getaddrinfo ENOTFOUND localhost:10309' when calling http.request --- src/Straightforward.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Straightforward.ts b/src/Straightforward.ts index b31989b..fdae092 100644 --- a/src/Straightforward.ts +++ b/src/Straightforward.ts @@ -294,7 +294,7 @@ export class Straightforward extends EventEmitter { } else { const urlParts = new URL(req.url) req.locals.urlParts = { - host: urlParts.host, + host: urlParts.hostname, port: parseInt(urlParts.port || "80"), path: urlParts.pathname + urlParts.search, }