@@ -654,6 +654,38 @@ async function run () {
654
654
} )
655
655
t . equal ( resultUnproxied . body , 'this is unproxied a' )
656
656
} )
657
+
658
+ test ( 'prefixed proxy with query search' , async t => {
659
+ const appServer = Fastify ( )
660
+
661
+ appServer . get ( '/second-service' , async ( request , reply ) => {
662
+ return `Hello World - lang = ${ request . query . lang } `
663
+ } )
664
+ appServer . get ( '/second-service/foo' , async ( request , reply ) => {
665
+ return `Hello World (foo) - lang = ${ request . query . lang } `
666
+ } )
667
+ const address = await appServer . listen ( 0 )
668
+
669
+ const proxyServer = Fastify ( )
670
+ proxyServer . register ( proxy , {
671
+ upstream : `${ address } /second-service` ,
672
+ prefix : '/second-service'
673
+ } )
674
+ const proxyAddress = await proxyServer . listen ( 0 )
675
+
676
+ t . teardown ( appServer . close . bind ( appServer ) )
677
+ t . teardown ( proxyServer . close . bind ( proxyServer ) )
678
+
679
+ const resultRoot = await got (
680
+ `${ proxyAddress } /second-service?lang=en`
681
+ )
682
+ t . equal ( resultRoot . body , 'Hello World - lang = en' )
683
+
684
+ const resultFooRoute = await got (
685
+ `${ proxyAddress } /second-service/foo?lang=en`
686
+ )
687
+ t . equal ( resultFooRoute . body , 'Hello World (foo) - lang = en' )
688
+ } )
657
689
}
658
690
659
691
run ( )
0 commit comments