File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ function Server(compiler, options) {
159
159
target : options . proxy [ context ]
160
160
} ;
161
161
} else {
162
- proxyOptions = options . proxy [ context ] ;
162
+ proxyOptions = Object . assign ( { } , options . proxy [ context ] ) ;
163
163
proxyOptions . context = correctedContext ;
164
164
}
165
165
proxyOptions . logLevel = proxyOptions . logLevel || "warn" ;
Original file line number Diff line number Diff line change @@ -144,4 +144,44 @@ describe("Proxy", function() {
144
144
. expect ( 200 , "from proxy2" , done ) ;
145
145
} ) ;
146
146
} ) ;
147
+
148
+ context ( "sharing a proxy option" , function ( ) {
149
+ let server ;
150
+ let req ;
151
+ let listener ;
152
+ const proxyTarget = {
153
+ target : "http://localhost:9000"
154
+ } ;
155
+
156
+ before ( function ( done ) {
157
+ const proxy = express ( ) ;
158
+ proxy . get ( "*" , function ( req , res ) {
159
+ res . send ( "from proxy" ) ;
160
+ } ) ;
161
+ listener = proxy . listen ( 9000 ) ;
162
+ server = helper . start ( config , {
163
+ contentBase,
164
+ proxy : {
165
+ "/proxy1" : proxyTarget ,
166
+ "/proxy2" : proxyTarget ,
167
+ }
168
+ } , done ) ;
169
+ req = request ( server . app ) ;
170
+ } ) ;
171
+
172
+ after ( function ( done ) {
173
+ helper . close ( function ( ) {
174
+ listener . close ( ) ;
175
+ done ( ) ;
176
+ } ) ;
177
+ } ) ;
178
+
179
+ it ( "respects proxy1 option" , function ( done ) {
180
+ req . get ( "/proxy1" ) . expect ( 200 , "from proxy" , done ) ;
181
+ } ) ;
182
+
183
+ it ( "respects proxy2 option" , function ( done ) {
184
+ req . get ( "/proxy2" ) . expect ( 200 , "from proxy" , done ) ;
185
+ } ) ;
186
+ } ) ;
147
187
} ) ;
You can’t perform that action at this time.
0 commit comments