Ionic/Angular $http.post results in a 404, but only on an Android phone, not on an iPhone or in the browser

I have updated to cordova v 5 (to fix ios9 issues) and run into this issue when recompiling my android version. Lucky me (not)…

Anyhow the purpose of my post is to share the solution that worked for me, restoring my ability to use the jsonp data service that was previously working before ios9 surfaced it’s ugly head.

There was no need to load cordova whitelist plugin, it’s included now if you’re cordova v5.
At least after I uninstalled and reinstalled cordova and ionic, then re-added the android platform I saw it show up in the list of plugins being added to my project (in the terminal output).

Adding this code to my config.xml did the trick and I’m back in business (except the lost 5 hours, messing around trying to fix this silly issue - not realising exactly what it was.)

<allow-navigation href="https://*/*" /> <allow-navigation href="data:*" />

See full message here :: stackoverflow answer

just paste into config.xml and bingo bango !!

Then i added this to index.html

<meta http-equiv="Content-Security-Policy" content="default-src 'self' https: ; style-src 'self' 'unsafe-inline'; script-src 'self' https: 'unsafe-inline' 'unsafe-eval' ">

no need for ngCsp tags in index.html either.

hope this helps save somebody else’s time

thanks

Steve

1 Like

When trying to solve this issue, be sure to build your apk locally and not through ionic package service. When I apply all of the above to solve the 404 on android issue and use ionic package service to build, the problem still exists. If I build locally, then it works.

Cheers
Antoni

Thanks for your reply I discovered the problem is my ionic css uses height:100% for slider, slider-slider and slider-slides

Adding a fixed height for slider solved the problem.
Therefore I think there is something in my legacy code that doesn’t like the new ionic 1.7.10 / 1.1.1 code.

I also uninstalled cordova and ionic and ran npm clear cache and reinstalled to try to resolve issue but it didn’t work so I went with fixed height.

Hopefully in version 1.2 of my app I’ll be able to remove this fix

thanks

***** Solved - Sansumg J7

try:

$ cordova plugin add cordova-plugin-whitelist
$ cordova prepare

and add the directive ngCsp

I also had this problem and searched a lot then finally… i removed the whitelist plugin:

cordova plugin remove cordova-plugin-whitelist
then renstalled it

cordova plugin add cordova-plugin-whitelist
It helped me and hope it solve your problem

3 Likes

I don’t know if this would be directly relevant to the original poster, but I came across this thread when trying to fix a very similar issue. I was getting an error, just on Android, when making any this.http.get request. Turned out that I was missing the “Internet” permission in the AndroidManifest.xml. Once I added:

<uses-permission android:name=“android.permission.INTERNET” />

my error disappeared. Hope this helps anyone facing the same problem.

1 Like

Thanks chris I was pulling my hair out on this and looks like this did it! :smile: