@@ -62,7 +62,10 @@ const getProxyMiddlewareHandler = () => {
6262 expect ( middleware . before ) . toEqual ( [ 'server-static' ] ) ;
6363 expect ( typeof middleware . handler ) . toBe ( 'function' ) ;
6464 return middleware . handler as (
65- c : { req : { url : string } ; res ?: Response } ,
65+ c : {
66+ req : { url : string ; headers ?: { get ?: ( name : string ) => string | null } } ;
67+ res ?: Response ;
68+ } ,
6669 next : ( ) => Promise < void > ,
6770 ) => Promise < void > ;
6871} ;
@@ -228,6 +231,32 @@ describe('rsc-mf host modern.server middleware contracts', () => {
228231 expect ( context . res ) . toBeUndefined ( ) ;
229232 } ) ;
230233
234+ it ( 'skips proxying when request is marked as internal fallback fetch' , async ( ) => {
235+ const handler = getProxyMiddlewareHandler ( ) ;
236+ const next = jest . fn ( async ( ) : Promise < void > => undefined ) ;
237+ const fetchMock = installFetchMock (
238+ async ( ) => new Response ( 'ignored' , { status : 200 } ) ,
239+ ) ;
240+ const context : {
241+ req : { url : string ; headers ?: { get ?: ( name : string ) => string | null } } ;
242+ res ?: Response ;
243+ } = {
244+ req : {
245+ url : 'http://127.0.0.1:3007/static/js/async/__federation_expose_actions.44d8f1d7ae.js' ,
246+ headers : {
247+ get : ( name : string ) =>
248+ name === INTERNAL_FALLBACK_HEADER ? '1' : undefined ,
249+ } ,
250+ } ,
251+ } ;
252+
253+ await withRemotePort ( '3999' , ( ) => handler ( context , next ) ) ;
254+
255+ expect ( fetchMock ) . not . toHaveBeenCalled ( ) ;
256+ expect ( next ) . toHaveBeenCalledTimes ( 1 ) ;
257+ expect ( context . res ) . toBeUndefined ( ) ;
258+ } ) ;
259+
231260 it ( 'falls through when remote port is not configured' , async ( ) => {
232261 const handler = getProxyMiddlewareHandler ( ) ;
233262 const next = jest . fn ( async ( ) : Promise < void > => undefined ) ;
0 commit comments