File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,9 @@ function Server(compiler, options) {
127127 contentBase = process . cwd ( ) ;
128128 }
129129
130+ // Keep track of websocket proxies for external websocket upgrade.
131+ const websocketProxies = [ ] ;
132+
130133 const features = {
131134 compress ( ) {
132135 if ( options . compress ) {
@@ -205,6 +208,9 @@ function Server(compiler, options) {
205208 }
206209
207210 proxyMiddleware = getProxyMiddleware ( proxyConfig ) ;
211+ if ( proxyConfig . ws ) {
212+ websocketProxies . push ( proxyMiddleware ) ;
213+ }
208214
209215 app . use ( ( req , res , next ) => {
210216 if ( typeof proxyConfigOrCallback === "function" ) {
@@ -361,6 +367,12 @@ function Server(compiler, options) {
361367 } else {
362368 this . listeningApp = http . createServer ( app ) ;
363369 }
370+
371+ // Proxy websockets without the initial http request
372+ // https://github.com/chimurai/http-proxy-middleware#external-websocket-upgrade
373+ websocketProxies . forEach ( function ( wsProxy ) {
374+ this . listeningApp . on ( "upgrade" , wsProxy . upgrade ) ;
375+ } ) ;
364376}
365377
366378Server . prototype . use = function ( ) {
You can’t perform that action at this time.
0 commit comments