Ionic CORS problem


#1

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 http://blog.ionic.io/handling-cors-issues-in-ionic/

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


#2

Did you try to set the right headers for cors?

Access-Control-Allow-Origin: *

see http://enable-cors.org/server.html


#3

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.


#4

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


#5

have you tried with CORS for chrome?

I dont understand your last post


#6

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