@@ -134,19 +134,25 @@ function Server(compiler, options) {
134
134
}
135
135
options . proxy . forEach ( function ( proxyOptions ) {
136
136
proxyOptions . ws = proxyOptions . hasOwnProperty ( 'ws' ) ? proxyOptions . ws : true ;
137
- app . all ( proxyOptions . path , function ( req , res ) {
138
- if ( typeof proxyOptions . rewrite === 'function' ) proxyOptions . rewrite ( req , proxyOptions ) ;
139
- if ( proxyOptions . host ) {
140
- req . headers . host = proxyOptions . host ;
141
- }
142
- proxy . web ( req , res , proxyOptions , function ( err ) {
143
- var msg = "cannot proxy to " + proxyOptions . target + " (" + err . message + ")" ;
144
- this . io . sockets . emit ( "proxy-error" , [ msg ] ) ;
145
- res . statusCode = 502 ;
146
- res . end ( ) ;
147
- } . bind ( this ) ) ;
148
- if ( proxyOptions . configure ) {
149
- proxyOptions . configure ( proxy ) ;
137
+ app . all ( proxyOptions . path , function ( req , res , next ) {
138
+ var bypassUrl = typeof proxyOptions . bypass === 'function' ? proxyOptions . bypass ( req , res , proxyOptions ) : false ;
139
+ if ( bypassUrl ) {
140
+ req . url = bypassUrl ;
141
+ next ( ) ;
142
+ } else {
143
+ if ( typeof proxyOptions . rewrite === 'function' ) proxyOptions . rewrite ( req , proxyOptions ) ;
144
+ if ( proxyOptions . host ) {
145
+ req . headers . host = proxyOptions . host ;
146
+ }
147
+ proxy . web ( req , res , proxyOptions , function ( err ) {
148
+ var msg = "cannot proxy to " + proxyOptions . target + " (" + err . message + ")" ;
149
+ this . io . sockets . emit ( "proxy-error" , [ msg ] ) ;
150
+ res . statusCode = 502 ;
151
+ res . end ( ) ;
152
+ } . bind ( this ) ) ;
153
+ if ( proxyOptions . configure ) {
154
+ proxyOptions . configure ( proxy ) ;
155
+ }
150
156
}
151
157
} . bind ( this ) ) ;
152
158
} . bind ( this ) ) ;
0 commit comments