@@ -49,6 +49,16 @@ const proxyOptionPathsAsProperties = {
49
49
}
50
50
} ,
51
51
} ,
52
+ "/bypass-with-target" : {
53
+ target : `http://localhost:${ port1 } ` ,
54
+ changeOrigin : true ,
55
+ secure : false ,
56
+ bypass ( req ) {
57
+ if ( / \. ( h t m l ) $ / i. test ( req . url ) ) {
58
+ return req . url ;
59
+ }
60
+ } ,
61
+ } ,
52
62
} ;
53
63
54
64
const proxyOption = {
@@ -223,6 +233,19 @@ describe("proxy option", () => {
223
233
expect ( response . status ) . toEqual ( 200 ) ;
224
234
expect ( response . text ) . toContain ( "proxy async response" ) ;
225
235
} ) ;
236
+
237
+ it ( "should work with the 'target' option" , async ( ) => {
238
+ const response = await req . get ( "/bypass-with-target/foo.js" ) ;
239
+
240
+ expect ( response . status ) . toEqual ( 404 ) ;
241
+ } ) ;
242
+
243
+ it ( "should work with the 'target' option #2" , async ( ) => {
244
+ const response = await req . get ( "/bypass-with-target/index.html" ) ;
245
+
246
+ expect ( response . status ) . toEqual ( 200 ) ;
247
+ expect ( response . text ) . toContain ( "Hello" ) ;
248
+ } ) ;
226
249
} ) ;
227
250
} ) ;
228
251
@@ -235,10 +258,6 @@ describe("proxy option", () => {
235
258
236
259
server = new Server (
237
260
{
238
- static : {
239
- directory : staticDirectory ,
240
- watch : false ,
241
- } ,
242
261
proxy : proxyOption ,
243
262
port : port3 ,
244
263
} ,
@@ -274,10 +293,6 @@ describe("proxy option", () => {
274
293
275
294
server = new Server (
276
295
{
277
- static : {
278
- directory : staticDirectory ,
279
- watch : false ,
280
- } ,
281
296
proxy : proxyWithString ,
282
297
port : port3 ,
283
298
} ,
@@ -313,10 +328,6 @@ describe("proxy option", () => {
313
328
314
329
server = new Server (
315
330
{
316
- static : {
317
- directory : staticDirectory ,
318
- watch : false ,
319
- } ,
320
331
proxy : proxyWithPath ,
321
332
port : port3 ,
322
333
} ,
@@ -352,10 +363,6 @@ describe("proxy option", () => {
352
363
353
364
server = new Server (
354
365
{
355
- static : {
356
- directory : staticDirectory ,
357
- watch : false ,
358
- } ,
359
366
proxy : proxyWithRouterAsObject ,
360
367
port : port3 ,
361
368
} ,
@@ -391,10 +398,6 @@ describe("proxy option", () => {
391
398
392
399
server = new Server (
393
400
{
394
- static : {
395
- directory : staticDirectory ,
396
- watch : false ,
397
- } ,
398
401
proxy : proxyOptionOfArray ,
399
402
port : port3 ,
400
403
} ,
@@ -444,10 +447,6 @@ describe("proxy option", () => {
444
447
445
448
server = new Server (
446
449
{
447
- static : {
448
- directory : staticDirectory ,
449
- watch : false ,
450
- } ,
451
450
proxy : proxyOptionOfArrayWithoutTarget ,
452
451
port : port3 ,
453
452
} ,
@@ -488,10 +487,6 @@ describe("proxy option", () => {
488
487
489
488
server = new Server (
490
489
{
491
- static : {
492
- directory : staticDirectory ,
493
- watch : false ,
494
- } ,
495
490
proxy : {
496
491
"/proxy1" : proxyTarget ,
497
492
"/proxy2" : proxyTarget ,
@@ -553,10 +548,6 @@ describe("proxy option", () => {
553
548
554
549
server = new Server (
555
550
{
556
- static : {
557
- directory : staticDirectory ,
558
- watch : false ,
559
- } ,
560
551
webSocketServer : webSocketServerType ,
561
552
proxy : [
562
553
{
@@ -623,10 +614,6 @@ describe("proxy option", () => {
623
614
624
615
server = new Server (
625
616
{
626
- static : {
627
- directory : staticDirectory ,
628
- watch : false ,
629
- } ,
630
617
proxy : {
631
618
"**" : proxyTarget ,
632
619
} ,
@@ -755,10 +742,6 @@ describe("proxy option", () => {
755
742
756
743
server = new Server (
757
744
{
758
- static : {
759
- directory : staticDirectory ,
760
- watch : false ,
761
- } ,
762
745
proxy : {
763
746
"*" : {
764
747
context : ( ) => true ,
@@ -808,10 +791,6 @@ describe("proxy option", () => {
808
791
809
792
server = new Server (
810
793
{
811
- static : {
812
- directory : staticDirectory ,
813
- watch : false ,
814
- } ,
815
794
proxy : {
816
795
"/my-path" : {
817
796
target : "http://unknown:1234" ,
@@ -863,10 +842,6 @@ describe("proxy option", () => {
863
842
864
843
server = new Server (
865
844
{
866
- static : {
867
- directory : staticDirectory ,
868
- watch : false ,
869
- } ,
870
845
proxy : {
871
846
"/my-path" : {
872
847
target : "http://unknown:1234" ,
@@ -921,10 +896,6 @@ describe("proxy option", () => {
921
896
922
897
server = new Server (
923
898
{
924
- static : {
925
- directory : staticDirectory ,
926
- watch : false ,
927
- } ,
928
899
proxy : {
929
900
"/my-path" : {
930
901
target : "http://unknown:1234" ,
@@ -978,10 +949,6 @@ describe("proxy option", () => {
978
949
979
950
server = new Server (
980
951
{
981
- static : {
982
- directory : staticDirectory ,
983
- watch : false ,
984
- } ,
985
952
proxy : {
986
953
"/my-path" : {
987
954
target : "http://unknown:1234" ,
0 commit comments