@@ -190,17 +190,16 @@ function addMiddleware(devServer) {
190190 // Tip: use https://jex.im/regulex/ to visualize the regex
191191 // var mayProxy = /^(?!\/(index\.html$|.*\.hot-update\.json$|sockjs-node\/)).*$/;
192192 // var mayProxy = /^\/api.*$/;
193+ var mayProxy = new RegExp ( '^' + middlewarePath + '.*$' ) ;
193194
194195 // Pass the scope regex both to Express and to the middleware for proxying
195196 // of both HTTP and WebSockets to work without false positives.
196197 // var hpm = httpProxyMiddleware(pathname => mayProxy.test(pathname), {
197- var hpm = httpProxyMiddleware ( {
198+ var hpm = httpProxyMiddleware ( path => mayProxy . test ( path ) , {
198199 target : proxy ,
199200 logLevel : 'silent' ,
200201 onProxyReq : function ( proxyReq , req , res ) {
201-
202- if ( proxyReq . getHeader ( 'authorization' ) )
203- proxyReq . setHeader ( 'authorization' , token ) ;
202+ proxyReq . setHeader ( 'authorization' , token ) ;
204203 } ,
205204 // pathRewrite: {
206205 // // '^/api/old-path': '/api/new-path', // rewrite path
@@ -211,8 +210,8 @@ function addMiddleware(devServer) {
211210 changeOrigin : true ,
212211 ws : true
213212 } ) ;
214- // devServer.use(mayProxy, hpm);
215- devServer . use ( middlewarePath , hpm ) ;
213+ devServer . use ( mayProxy , hpm ) ;
214+ // devServer.use(middlewarePath, hpm);
216215
217216 // Listen for the websocket 'upgrade' event and upgrade the connection.
218217 // If this is not done, httpProxyMiddleware will not try to upgrade until
0 commit comments