Sendig a GET request to REST API from phone app

64 views Asked by At

I have an app that I made using Apache Cordova (it turns HTML/CSS/JS websites into an app, basically). It sends a simple GET request to my REST API that is running locally on a PC. I'm using the local (not localhost) IP of the PC (192.168.x.x) and the right port, but it doesn't seem to work. However, I am able to do it "manually" through the browser on my phone by typing in the address and port.
<uses-permission name="android.permission.INTERNET" /> is already in the .xml file. my Firewall is deactivated and my network is set to "private network".

EDIT 20.3.2020 13:08: I realized I was looking at the wrong .xml file, but the problem still persists. Adding the whole config.xml file for clarity.

<xml version='1.0' encoding='utf-8'?> <widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <feature name="Whitelist"> <param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin" /> <param name="onload" value="true" /> </feature> <uses-permission name="android.permission.INTERNET" /> <name></name> <content src="index.html" /> <access origin="*" /> <allow-intent href="*"/> <allow-intent href="http://*/*" /> <allow-intent href="https://*/*" /> <allow-intent href="tel:*" /> <allow-intent href="sms:*" /> <allow-intent href="mailto:*" /> <allow-intent href="geo:*" /> <allow-intent href="market:*" /> <preference name="loglevel" value="DEBUG" /> </widget>

1

There are 1 answers

4
Durzan On BEST ANSWER

You have to add the following entry to you config.xml so GET requests are allowed

<access origin="192.168.x.x" />