[cli] Support WebSocket upgrades in dev (#4241)
[cli] Support WebSocket upgrades in dev (#4241)

We were already using `http-proxy`'s WebSockets option, but we were missing a step! In addition to setting `{ws: true}`, you must also forward WebSocket upgrade events from the front-facing server to the proxy. [(See this example.)](https://github.com/http-party/node-http-proxy#proxying-websockets)

Previously, the proxy server and client _would_ mutually agree to "upgrade" their connection (because we set `{ws: true}`)… but then, when the client would start sending WebSocket data instead of HTTP data, our front-facing server would drop it, because we hadn't configured a place for it to go.

In this change, we configure `this.server` to forward its `upgrade` events to the proxy server.

We also refactor `proxyPass` to use the new shared `this.proxy` instance responsible for the `upgrade` events, instead of creating a new proxy instance for every request. This isn't strictly necessary, but a helpful simplification to clarify that there's no specific reason for the proxy instances to be _different_ than the instance that manages WebSocket upgrades!

This fixes #3451: CRA apps can now auto-refresh when the source code changes, and Firefox can now load the app without crashing on the 6th attempt.

Co-authored-by: Steven <4068f0880b399410602d694b3cc711c8a8f4727e@ceriously.com>
zeit/now-cli,zeit/now-cli,zeit/now-cli,zeit/now-cli,zeit/now-cli,zeit/now-cli,zeit/now-cli