import { MOBILE_PROSE_HOST , MOBILE_PROSE_PORT } from '@env' ; import Constants from 'expo-constants' ; const { manifest } = Constants ; function getProseEndpoint ( ) { const hostName = MOBILE_PROSE_HOST ; if ( ! hostName ) { throw new Error ( 'MOBILE_PROSE_HOST must be set.' ) ; } if ( ! hostName . startsWith ( 'http://' ) && ! hostName . startsWith ( 'https://' ) ) { throw new Error ( 'MOBILE_PROSE_HOST must start with http:// or https://' ) ; } const delimitedProsePort = MOBILE_PROSE_PORT ? `:${ MOBILE_PROSE_PORT }` : '' ; const defaultValue = `${ hostName }${ delimitedProsePort }` ; if ( process . env . NODE_ENV === 'production' ) { return defaultValue ; } if ( ! hostName . includes ( '://localhost' ) && ! hostName . includes ( '://127.0.0.1' ) ) { return defaultValue ; } const { debuggerHost } = manifest ?? { } ; if ( ! debuggerHost ) { return defaultValue ; } const machineHost = debuggerHost . split ( ':' ) [ 0 ] ; if ( ! machineHost ) { return defaultValue ; } return `http://${ machineHost }${ delimitedProsePort }` ; } export const PROSE_ENDPOINT = getProseEndpoint ( ) ;