You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I enable ws: true, it proxies my websocket request successfully. However, when I refresh the page, 2 websocket requests are made to the server, resulting in Invalid frame header errors. When I refresh the page again, 3 websocket requests are made, and so on.
I have the feeling that a new server.on('upgrade' events is registered whenever.
Step-by-step reproduction instructions
1. Use https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/servers.md#nextjs
2. Enable `ws: true`
3. Make a page which creates a websocket on `/api/something`
4. Refresh page multiple times
5. See the number of new websockets grow with each refresh
Expected behavior (be clear and concise)
I would expect that http-proxy-middleware would not create multiple websockets when I create 1 websocket.
How is http-proxy-middleware used in your project?
> $ yarn why http-proxy-middleware
yarn why v1.22.19
[1/4] Why do we have the module "http-proxy-middleware"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "[email protected]"
info Has been hoisted to "http-proxy-middleware"
info This module exists because it's specified in "dependencies".info Disk size without dependencies: "560KB"info Disk size with unique dependencies: "2.82MB"info Disk size with transitive dependencies: "4.16MB"info Number of shared dependencies: 16Done in 1.21s.
What http-proxy-middleware configuration are you using?
Checks
http-proxy-middleware
.Describe the bug (be clear and concise)
I have used the recipe for next.js and API routes: https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/servers.md#nextjs
When I enable
ws: true
, it proxies my websocket request successfully. However, when I refresh the page, 2 websocket requests are made to the server, resulting inInvalid frame header
errors. When I refresh the page again, 3 websocket requests are made, and so on.I have the feeling that a new
server.on('upgrade'
events is registered whenever.Step-by-step reproduction instructions
Expected behavior (be clear and concise)
I would expect that
http-proxy-middleware
would not create multiple websockets when I create 1 websocket.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)
For now, changing the handler to read from a global variable works:
Any suggestions?
The text was updated successfully, but these errors were encountered: