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) {
127
127
contentBase = process . cwd ( ) ;
128
128
}
129
129
130
+ // Keep track of websocket proxies for external websocket upgrade.
131
+ const websocketProxies = [ ] ;
132
+
130
133
const features = {
131
134
compress ( ) {
132
135
if ( options . compress ) {
@@ -205,6 +208,9 @@ function Server(compiler, options) {
205
208
}
206
209
207
210
proxyMiddleware = getProxyMiddleware ( proxyConfig ) ;
211
+ if ( proxyConfig . ws ) {
212
+ websocketProxies . push ( proxyMiddleware ) ;
213
+ }
208
214
209
215
app . use ( ( req , res , next ) => {
210
216
if ( typeof proxyConfigOrCallback === "function" ) {
@@ -361,6 +367,12 @@ function Server(compiler, options) {
361
367
} else {
362
368
this . listeningApp = http . createServer ( app ) ;
363
369
}
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
+ } ) ;
364
376
}
365
377
366
378
Server . prototype . use = function ( ) {
You can’t perform that action at this time.
0 commit comments