next-http-proxy-middleware icon indicating copy to clipboard operation
next-http-proxy-middleware copied to clipboard

1.1.* introduces a bug in pathRewrite option

Open ctrlaltdylan opened this issue 4 years ago • 1 comments

Hi,

I was using the old signature for pathRewrite of a plan object, with the key as the test pattern & the value being the replacement string.

This was working great with v1.0.* of the library, but it seems like the new v1.1.* introduce change broke this compatiblity.

httpProxyMiddleware(req, res, {
    target: `https://${shop.name}/admin/api/2021-10/graphql.json`,
    headers: {
      "Content-Type": "application/json",
      "X-Shopify-Access-Token": shop.accessToken,
    },
    changeOrigin: true,
    ws: true,
    pathRewrite: {
      "^/api/graphql": "",
    },
  });

I attempted to use the new Array based syntax:

    pathRewrite: [{
      patternStr: "^/api/graphql",
      replaceStr: ""
    }],
  });

But the without being able to visualize the request, I'm not sure why that request is being rejected by the host.

I just know that downgrading and keeping the old signature works for my case.

Leaving this for documentation purposes, maybe I'll get around to adding a debugging mode or something to view the request's parameters easier.

ctrlaltdylan avatar Nov 15 '21 15:11 ctrlaltdylan

Hi @ctrlaltdylan

Thanks for your reporting 😀

I have a few questions to check this issue.

  • Can you tell me the URL value to input from the client and the URL value to convert?
    • If possible, would you like to download the source code from this repository, write a test case referring to the /index.test.ts file, and check if the URL is converted properly?
  • What response did you get from the server? (e.g. 404 response, pending status, etc..)

Thanks 😀

stegano avatar Nov 17 '21 07:11 stegano