File tree 1 file changed +17
-10
lines changed
1 file changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -205,16 +205,23 @@ function addMiddleware(devServer) {
205
205
// - /sockjs-node/* (WebpackDevServer uses this for hot reloading)
206
206
// Tip: use https://www.debuggex.com/ to visualize the regex
207
207
var mayProxy = / ^ (? ! \/ ( i n d e x \. h t m l $ | .* \. h o t - u p d a t e \. j s o n $ | s o c k j s - n o d e \/ ) ) .* $ / ;
208
- devServer . use ( mayProxy ,
209
- // Pass the scope regex both to Express and to the middleware for proxying
210
- // of both HTTP and WebSockets to work without false positives.
211
- httpProxyMiddleware ( pathname => mayProxy . test ( pathname ) , {
212
- target : proxy ,
213
- logLevel : 'silent' ,
214
- secure : false ,
215
- changeOrigin : true
216
- } )
217
- ) ;
208
+
209
+ // Pass the scope regex both to Express and to the middleware for proxying
210
+ // of both HTTP and WebSockets to work without false positives.
211
+ var hpm = httpProxyMiddleware ( pathname => mayProxy . test ( pathname ) , {
212
+ target : proxy ,
213
+ logLevel : 'silent' ,
214
+ onError : onProxyError ( proxy ) ,
215
+ secure : false ,
216
+ changeOrigin : true ,
217
+ ws : true
218
+ } ) ;
219
+ devServer . use ( mayProxy , hpm ) ;
220
+
221
+ // Listen for the websocket 'upgrade' event and upgrade the connection.
222
+ // If this is not done, httpProxyMiddleware will not try to upgrade until
223
+ // an initial plain HTTP request is made.
224
+ devServer . listeningApp . on ( 'upgrade' , hpm . upgrade ) ;
218
225
}
219
226
// Finally, by now we have certainly resolved the URL.
220
227
// It may be /index.html, so let the dev server try serving it again.
You can’t perform that action at this time.
0 commit comments