@@ -311,6 +311,7 @@ async function diagArrayBufferSelfTest(): Promise<void> {
311311 // Iterate specs until one returns an IP — many countries (AU, BR, …) aren't
312312 // deployed and return an empty list, so specs[0] alone tells us nothing.
313313 let ip : string | undefined ;
314+ let hitSpec : string | undefined ;
314315 let lastStatus = 0 ;
315316 let tried = 0 ;
316317 for ( const spec of specs ) {
@@ -322,6 +323,7 @@ async function diagArrayBufferSelfTest(): Promise<void> {
322323 const found = loc . data ?. [ 0 ] ?. ip ?. split ( ':' ) [ 0 ] ;
323324 if ( found ) {
324325 ip = found ;
326+ hitSpec = spec ;
325327 steps . push ( `fluxAPI ${ spec } =${ locRes . status } ip=${ found } (after ${ tried } )` ) ;
326328 break ;
327329 }
@@ -334,22 +336,29 @@ async function diagArrayBufferSelfTest(): Promise<void> {
334336 steps . push ( `no ip from ${ tried } specs (last status ${ lastStatus } )` ) ;
335337 }
336338 if ( ip ) {
337- const url = `http:// ${ ip } :51821/v1/info` ;
339+ // A) cleartext, straight to the gateway IP (what discovery does today).
338340 try {
339- const res = await fetch ( url ) ;
340- steps . push ( `gateway=${ res . status } ` ) ;
341- try {
342- steps . push ( `arrayBuffer=${ ( await res . clone ( ) . arrayBuffer ( ) ) . byteLength } B` ) ;
343- } catch ( e ) {
344- steps . push ( `arrayBuffer=ERR ${ String ( ( e as Error ) ?. message ?? e ) } ` ) ;
345- }
341+ const res = await fetch ( `http://${ ip } :51821/v1/info` ) ;
342+ steps . push ( `cleartext=${ res . status } ` ) ;
343+ } catch ( e ) {
344+ steps . push ( `cleartext=FETCH_ERR ${ String ( ( e as Error ) ?. message ?? e ) } ` ) ;
345+ }
346+ }
347+ if ( hitSpec ) {
348+ // B) HTTPS via the per-country FDM domain (valid cert). If this works while
349+ // cleartext fails, HTTPS is the escape hatch for iOS.
350+ const httpsUrl = `https://${ hitSpec } _51821.app.runonflux.io/v1/info` ;
351+ try {
352+ const res = await fetch ( httpsUrl ) ;
353+ let ab = 'n/a' ;
346354 try {
347- steps . push ( `text= ${ ( await res . text ( ) ) . length } chars` ) ;
355+ ab = ` ${ ( await res . clone ( ) . arrayBuffer ( ) ) . byteLength } B` ;
348356 } catch ( e ) {
349- steps . push ( `text= ERR ${ String ( ( e as Error ) ?. message ?? e ) } `) ;
357+ ab = ` ERR ${ String ( ( e as Error ) ?. message ?? e ) } `;
350358 }
359+ steps . push ( `https=${ res . status } arrayBuffer=${ ab } ` ) ;
351360 } catch ( e ) {
352- steps . push ( `gateway =FETCH_ERR ${ String ( ( e as Error ) ?. message ?? e ) } ` ) ;
361+ steps . push ( `https =FETCH_ERR ${ String ( ( e as Error ) ?. message ?? e ) } ` ) ;
353362 }
354363 }
355364 } catch ( e ) {
0 commit comments