Checks
Describe the bug (be clear and concise)
When http-proxy-middleware@3 receives a HTTP request, it passes the HTTP request URL to your configured pathFilter and uses this to determine whether or not to proxy this request through. With most requests, the base URI on which the middleware is mounted is removed from the URL. But for a WebSocket upgrade the base URI is left on.
Step-by-step reproduction instructions
This isn't a fully functional reproduce but it should give an idea. I have HPM configured like so:
app.use('/a/b/c', createProxyMiddleware({
target: 'http://localhost:4415',
ws: true,
pathFilter: pathname => {
console.log(pathname)
return pathname.startsWith('/api') ||
pathname.startsWith('/raw-ws')
})
Then the application listens on http://localhost:5056.
Expected behavior (be clear and concise)
When I make a HTTP request to http://localhost:5056/a/b/c/api/whatever, the console outputs:
, my filter returns true and HPM proxies the request through, correctly. Note how "/a/b/c" has been removed from pathname.
But when my application tries to open a web socket on http://localhost:5056/a/b/c/raw-ws, the console outputs:
, the filter returns false, and my filter does not proxy the request through. Currently I am working around this by altering my filter to say:
pathname.startsWith('/api') ||
pathname.startsWith('/a/b/c/raw-ws')
How is http-proxy-middleware used in your project?
*****@9.0.688
`-- http-proxy-middleware@3.0.0
What http-proxy-middleware configuration are you using?
{
target: 'http://localhost:4415',
ws: true,
pathFilter: pathname => {
console.log(pathname)
return pathname.startsWith('/api') ||
pathname.startsWith('/raw-ws')
}
What OS/version and node/version are you seeing the problem?
Additional context (optional)
Big fan of the V3 upgrade because it's taken a lot of manual base path management off my hands! Just this last little bit :)
Checks
http-proxy-middleware.Describe the bug (be clear and concise)
When
http-proxy-middleware@3receives a HTTP request, it passes the HTTP request URL to your configuredpathFilterand uses this to determine whether or not to proxy this request through. With most requests, the base URI on which the middleware is mounted is removed from the URL. But for a WebSocket upgrade the base URI is left on.Step-by-step reproduction instructions
This isn't a fully functional reproduce but it should give an idea. I have HPM configured like so:
Then the application listens on http://localhost:5056.
Expected behavior (be clear and concise)
When I make a HTTP request to http://localhost:5056/a/b/c/api/whatever, the console outputs:
, my filter returns
trueand HPM proxies the request through, correctly. Note how "/a/b/c" has been removed frompathname.But when my application tries to open a web socket on http://localhost:5056/a/b/c/raw-ws, the console outputs:
, the filter returns
false, and my filter does not proxy the request through. Currently I am working around this by altering my filter to say:How is http-proxy-middleware used in your project?
What http-proxy-middleware configuration are you using?
What OS/version and node/version are you seeing the problem?
Additional context (optional)
Big fan of the V3 upgrade because it's taken a lot of manual base path management off my hands! Just this last little bit :)