$http works on simulator and browser but not on iOS device

I’ve been searching high and low and haven’t found a solution that works for me. I can run the simulator and see that my $http.get requests hit my external api server just fine. Same results when running the app from within the browser.

I’m running a node/express server with CORS enabled:
app.use(function(req, res, next) {
res.header(“Access-Control-Allow-Origin”, “*”);
res.header(“Access-Control-Allow-Headers”, “Origin, X-Requested-With, Content-Type, Accept”);

However, when I load my app on my device with Xcode I get a 404 back from my api request. I don’t know how to debug the ionic view app but when I load my app inside the view app I don’t see any requests on my server.

What I can do is hit a public api from my app while it’s running in the device. That works just fine.

I have the whitelist plugin installed as it comes with ionic now.

In my config.xml I have:

$ ionic info

Your system information:

Cordova CLI: 5.4.0
Gulp version: CLI version 3.9.0
Gulp local: Local version 3.9.0
Ionic Version: 1.1.0
Ionic CLI Version: 1.7.7
Ionic App Lib Version: 0.6.3
ios-deploy version: 1.8.2
ios-sim version: 5.0.3
OS: Mac OS X El Capitan
Node Version: v4.2.0
Xcode version: Xcode 7.1.1 Build version 7B1005

Let me know if I’ve left any important information out.


Does your xcode debug console contain a message about App Transport Security or ATS?
Given you specifically mention iOS and you’re running El Cap & Xcode 7.1.1 I’m guessing your device is running iOS9?

If so you should check out: https://gist.github.com/mlynch/284699d676fe9ed0abfa

iOS 9 does not allow non-https calls. A temporary work around during dev is to disable this using the solution in the post.
In production you’ll want to https set up.

Hope that helps!

I forgot to mention that I do have ATS disabled at the top of my app’s plist file:


Yes, I’m running iOS9 - In fact I’m running 9.1

I know that ATS is working because I’ve tested a non-https public api and got a response back.

For what it’s worth here is Xcode’s debug message when I build my app:

2015-11-10 21:20:47.703 egMobile[1587:745391] Apache Cordova native platform version 3.9.2 is starting.
2015-11-10 21:20:47.704 egMobile[1587:745391] Multi-tasking -> Device: YES, App: YES
2015-11-10 21:20:47.706 egMobile[1587:745391] Unlimited access to network resources
2015-11-10 21:20:48.221 egMobile[1587:745391] Resetting plugins due to page load.
2015-11-10 21:20:48.523 egMobile[1587:745391] Finished load of: file:///var/mobile/Containers/Bundle/Application/44428BE0-4EE1-4467-A450-639E44DE714D/mobile.app/www/index.html#/app/activity

Issue resolved. It was a network issue, bah.