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”);
next();
});
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?
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.