File tree 1 file changed +12
-11
lines changed
1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -171,22 +171,23 @@ function Server(compiler, options) {
171
171
options . proxy . forEach ( function ( proxyConfig ) {
172
172
var bypass = typeof proxyConfig . bypass === 'function' ;
173
173
var context = proxyConfig . context || proxyConfig . path ;
174
+ var proxyMiddleware ;
175
+ // It is possible to use the `bypass` method without a `target`.
176
+ // However, the proxy middleware has no use in this case, and will fail to instantiate.
177
+ if ( proxyConfig . target ) {
178
+ proxyMiddleware = httpProxyMiddleware ( context , proxyConfig ) ;
179
+ }
174
180
175
- function bypassMiddleware ( req , res , next ) {
176
- var bypassUrl = proxyConfig . bypass ( req , res , proxyConfig ) || false ;
181
+ app . use ( function ( req , res , next ) {
182
+ var bypassUrl = bypass && proxyConfig . bypass ( req , res , proxyConfig ) || false ;
177
183
178
184
if ( bypassUrl ) {
179
185
req . url = bypassUrl ;
186
+ next ( ) ;
187
+ } else if ( proxyMiddleware ) {
188
+ return proxyMiddleware ( req , res , next ) ;
180
189
}
181
-
182
- next ( ) ;
183
- }
184
-
185
- if ( bypass ) {
186
- app . use ( bypassMiddleware ) ;
187
- } else {
188
- app . use ( httpProxyMiddleware ( context , proxyConfig ) ) ;
189
- }
190
+ } ) ;
190
191
} ) ;
191
192
}
192
193
} ,
You can’t perform that action at this time.
0 commit comments