From 8de28aafeff3854e416dbeac1a1fc1c483c0de7d Mon Sep 17 00:00:00 2001 From: Kevin Cheng Date: Mon, 22 Aug 2022 20:13:14 -0700 Subject: [PATCH] Remove trailing slash in proxyUrl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Infura has trouble handling requests with a trailing slash in API endpoint. https://github.com/INFURA/infura/issues/221 Credit to 🍯 for the find --- src/server.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/server.mjs b/src/server.mjs index 8bfbdc7..ae9b1cd 100644 --- a/src/server.mjs +++ b/src/server.mjs @@ -46,6 +46,7 @@ function getReqBody(req) { async function proxy(host, request, reqBody, response) { let pathname = url.parse(request.url).pathname; + pathname = pathname === "/" ? "" : pathname; // to avoid a trailing slash let hostname = url.parse(host).host; let proxyUrl = `${host}${pathname}`; let reqMethod = request.method;