@@ -268,6 +268,24 @@ if (enableApiCallLogs || isTest) {
268268 }
269269 }
270270
271+ // Hosts that bypass the mock proxy and make direct network requests.
272+ const PROXY_BYPASS_PATTERNS = [
273+ '.node.web3auth.io' ,
274+ '.uat-node.web3auth.io' ,
275+ 'auth-service.uat-api.cx.metamask.io' ,
276+ ] ;
277+
278+ const shouldBypassProxy = ( targetUrl ) => {
279+ try {
280+ const hostname = new URL ( targetUrl ) . hostname ;
281+ return PROXY_BYPASS_PATTERNS . some (
282+ ( p ) => hostname === p || hostname . endsWith ( p ) ,
283+ ) ;
284+ } catch {
285+ return false ;
286+ }
287+ } ;
288+
271289 // if mockServer is off we route to original destination
272290 global . fetch = async ( url , options ) => {
273291 // Extract URL string from Request or URL objects
@@ -283,7 +301,7 @@ if (enableApiCallLogs || isTest) {
283301 urlString = String ( url ) ;
284302 }
285303
286- if ( ! isMockServerAvailable ) {
304+ if ( ! isMockServerAvailable || shouldBypassProxy ( urlString ) ) {
287305 return originalFetch ( url , options ) ;
288306 }
289307
@@ -331,7 +349,8 @@ if (enableApiCallLogs || isTest) {
331349 }
332350 if (
333351 ! url . includes ( `localhost:${ mockServerPort } ` ) &&
334- ! url . includes ( '/proxy' )
352+ ! url . includes ( '/proxy' ) &&
353+ ! shouldBypassProxy ( url )
335354 ) {
336355 url = `${ MOCKTTP_URL } /proxy?url=${ encodeURIComponent ( url ) } ` ;
337356 }
@@ -416,6 +435,9 @@ if (enableApiCallLogs || isTest) {
416435 const originalExpoFetch = fetchSourceModule . fetch ;
417436 fetchSourceModule . fetch = ( url , options ) => {
418437 const urlStr = String ( url ) ;
438+ if ( shouldBypassProxy ( urlStr ) ) {
439+ return originalExpoFetch ( url , options ) ;
440+ }
419441 const proxyUrl = `${ MOCKTTP_URL } /proxy?url=${ encodeURIComponent ( urlStr ) } ` ;
420442 // eslint-disable-next-line no-console
421443 console . log ( `[E2E SHIM] expo/fetch: ${ urlStr } → ${ proxyUrl } ` ) ;
0 commit comments