From bec497e9a068bd169edc56614c07f66358444968 Mon Sep 17 00:00:00 2001 From: Peter Velkov Date: Wed, 9 Mar 2022 01:39:29 +0200 Subject: [PATCH] Use `ROOT/api` to avoid ngrok problems --- src/libs/NetworkConnection.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/libs/NetworkConnection.js b/src/libs/NetworkConnection.js index dd9276543e9b..7c3f041e36f6 100644 --- a/src/libs/NetworkConnection.js +++ b/src/libs/NetworkConnection.js @@ -53,18 +53,16 @@ function setOfflineStatus(isCurrentlyOffline) { */ function subscribeToNetInfo() { // Calling NetInfo.configure (re)checks current state. We use it to force a recheck whenever we (re)subscribe - if (CONFIG.IS_IN_PRODUCTION) { - NetInfo.configure({ - // By default, for web (including Electron) NetInfo uses `/` for `reachabilityUrl` - // When App is served locally or from Electron this would respond with OK even with no internet - // Using API url ensures reachability is tested over internet - reachabilityUrl: CONFIG.EXPENSIFY.URL_API_ROOT, - reachabilityTest: response => Promise.resolve(response.status === 200), - - // If a check is taking longer than this time we're considered offline - reachabilityRequestTimeout: CONST.NETWORK.MAX_PENDING_TIME_MS, - }); - } + NetInfo.configure({ + // By default, NetInfo uses `/` for `reachabilityUrl` + // When App is served locally (or from Electron) this address is always reachable - even offline + // Using the API url ensures reachability is tested over internet + reachabilityUrl: `${CONFIG.EXPENSIFY.URL_API_ROOT}api`, + reachabilityTest: response => Promise.resolve(response.status === 200), + + // If a check is taking longer than this time we're considered offline + reachabilityRequestTimeout: CONST.NETWORK.MAX_PENDING_TIME_MS, + }); // Subscribe to the state change event via NetInfo so we can update // whether a user has internet connectivity or not.