Ionic CORS problem


Hi, I tried to access the api on my server, but when I debug it through the browser or run it through ionic view, the error appears like this:

XMLHttpRequest cannot load http:/apiserver/api/. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost’ is therefore not allowed access.

I have found a tutorial here

and i tried all of them, but still failed… any idea?


Did you try to set the right headers for cors?

Access-Control-Allow-Origin: *



If you are working with Chrome install this component:

that fixed the problem. Although you have to install in your computer, in android it will work fine.


well, when I deploy to the ionic view, it still can’t access the api… in this case I access my login api, and still can’t access it


have you tried with CORS for chrome?

I dont understand your last post


I tried, but if in the chrome succeed , it is only used in development. do you know ionic view? Ionic android apps that let us deploy our ionic to the client app without installing the apk over and over again. Well by using that ionic view, my app still can’t access the api in the server