'How to make react native app communicate with local machine (ios)
I need to know ALL the things I need to do in order to allow a react native app communicate with a local server running on my mac. (I'm running react native on an ios device).
This is what I know of/have tried:
- Using the actual IP address of my machine instead of localhost
- Set up signing & capabilities in xcode
- Make sure both the iphone and computer are on the same network
- Make sure there are no firewalls up on the computer running the api
- Set the info.plist to "AllowArbitraryLoads = true"
Here's my full info.plist if you want to check it
I have been trying to get this simple react native app to communicate with a bare-bones flask app on my computer for like a week now, and I'm starting to lose my mind.
Assume I'm a complete moron. If there's something that "everybody knows and isn't worth mentioning", please mention it. If I didn't list it above, then I don't know about it. I feel like I'm missing a very simple step here but I cannot for the life of me figure out what it is.
Here are the error logs (i've tried googling the Flipper errors, with little success, so if you know anything about that please share):
Here's a link to a demo project I'm using to test this:
Solution 1:[1]
Finally figured out the last step I was missing...
When you run the flask app, you have to run it to be hosted on 0.0.0.0
rather than 127.0.0.1
which are both ways of referencing your local machine, but are treated slightly differently on the network.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Alec Mather |