Skip to content

Fix API requests to localhost on Android #168

@isaiahgrey93

Description

@isaiahgrey93

Finally was able to resolve an issue I've dealt with in several apps where on the Android platform, requests to localhost do not resolve despite adb reverse being called correctly.
I was able to fix this issue by modify the environment variable while in dev mode (_DEV_ = true) by pointing at 10.0.2.2 instead of localhost :

if (__DEV__ && Platform.OS === 'android') {
  ENV.API_URL = API_URL.replace('localhost', '10.0.2.2');
}

We should add this to our default setup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions