I am having a strange problem. I am not able to make Ajax call from the application in Android. However it works very well with normal browser setting. I have made the proper CORS setting at server.
I am getting 403 Forbidden . And it seems something is getting blocked in webview itself. Nothing is going to server.
One more thing that I noticed is that in Request Header , Origin is file:// .
I had the same problem and I solved it by turning off the CORS filter (by not using the CORS filter) on Tomcat.
Here is the detail.
(1) If you installed an app using ā$ ionic run androidā command, turn off the CORS filter on Tomcat.
Android Webview can access any site and it does not have a CORS issue like a regular Chrome browser.
For the same reason, you should not use the CORS filter on your production Tomcat server for the android mobile app accessing your site.
(2) If you installed an app using ā$ionic run --livereload androidā command during development, turn on the CORS filter on Tomcat.
When using āālivereloadā option, the appās āOriginā HTTP header will be sent with something like āhttp://localhost:9100ā. When Tomcat sees this Origin header with āhttp://ā, it will consider it as CORS access from a browser. So, the CORS filter needs to be turned on on Tomcat. In this case, if the CORS filter is not set up on Tomcat, the access will not be allowed.
I am running tcpdump and the Android emulator is not even making a network request at all. I have configured CORS correctly on the server-side, as I had to fix it for the iOS emulator ā which works fine now.
But when I launch ionic run android any AJAX request just immediately returns an error and tcpdump shows no traffic was sent to the server.
Normally with a CORS issue the browser will at least issue an HTTP OPTIONS request. The Android emulator isnāt sending any traffic when I launch the app.
This is exactly my problem too. My app works fine using āionic serveā and āionic emulateā, but as soon as I try it native on my Nexus 5 or Ionic View, I get a 403 Forbidden on my $http call.
I am in the same situation. Have you made any progress? I am able to make http and https calls from my devices (Android and iPhone), however my call to Amazon AWS using Javascript for Browser is getting a 403 Forbidden. Running the same code using āionic serveā works fine.