Skip to content

Commit

Permalink
Remove trailing slash in proxyUrl (#5)
Browse files Browse the repository at this point in the history
* Remove trailing slash in proxyUrl

Infura has trouble handling requests with a trailing slash in API endpoint. INFURA/infura#221

Credit to 🍯 for the find

* Remove trailing slashes directly from proxyUrl

* Revert latest change
  • Loading branch information
kevincheng96 authored Aug 23, 2022
1 parent 4226361 commit f491449
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f491449

Please sign in to comment.