next-http-proxy-middleware
next-http-proxy-middleware copied to clipboard
1.1.* introduces a bug in pathRewrite option
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.
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.tsfile, and check if the URL is converted properly?
- If possible, would you like to download the source code from this repository, write a test case referring to the
- What response did you get from the server? (e.g. 404 response, pending status, etc..)
Thanks 😀