Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ROOT/api to avoid ngrok problems #8049

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions src/libs/NetworkConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down