So I'm running into what's probably a typical issue and although there seems to be several related questions and answers here and here but they don't exactly apply to my question.
I have a local django server (localhost:8000) running in development. I would like to easily develop a Nativescript mobile app connecting to my django server by using Nativescript/Vue with Axios to make the http calls. I prefer to start development/testing in ios. I have two choices for development with Nativescript - either using 'tns run ios' which brings up the ios emulator on my mac or using 'tns preview' which allows me to test via my actual iphone.
When I am making a basic call via axios to http://localhost:8000/myapi that call yields an http status result of null.
- I tried using a loopback address (e.g., 10.0.2.2 - which I believe may work for the Android emulator) but that yielded the same result.
I tried using my local IP address of my mac - i.e., instead of localhost, using my local 192.168.xx.xx address for the call but that didn't work
I finally was able to get it working using ./ngrok to tunnel my local server to an outside IP address. Now that works, but it's not ideal since that IP address may change from time to time.
What is the suggested solution for easily connecting to my local api server using either Nativescript preview or running the ios emulator?