that im trying to pull in my app but im getting the:
Failed to load resource: Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin.
Thanks but I need it to work on my iOS and Android device. Not only on chrome. It seems that its looking for the file within then project not the website i gave it in the proxy settings. So the proxy settings arent working.
You can test it by running the ionic cordova run android command to test it on the device.
CORS is a restriction that the browser enforces via that it sends as a small string in the header that says that this is a Cross Origin Reference. You can handle the CORS problem in the browser by disabling it on the browser with the plugin I just gave you for chrome or you can enable CORS on your server to enable people to make requests for resources even if has the CORS header.
I have no problem working on android but on ios get the error of:
[Error] Failed to load resource: Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin. (news.json, line 0)
XMLHttpRequest cannot load https://www.mysite.com/json/news.json due to access control checks.
When you say IOS, are you running it in your browser on the Mac or are you creating an xcode project and trying to get the data from that end point? I think you are running it on a browser.
When you load the application to android, the request is not bound with a CORS header.
To understand CORS better look at this -
You can’t use
If you do that the request will look for the file locally. If you need to access your end point you need to include the whole URL.
Thanks! for clearing it up for me. Sorry for the confusion, I mean to say that on android its working fine. I used android studio to run it on my physical device. It works fine.
But when I use Xcode to run the app on my physical iPhone device, it still does not work. I fixed the getNews function to the whole URL as you suggested. But it still does not show on my ios physical device after running the app through xcode. I get an error of:
HTTP GET ERROR: Response with status: 0 for URL: null
i have this issue in bearer token from c#
api call from controller will be back but for token i have corss issue
content-type is application/x-www-form-urlencoded
response type is json
I am having the same issue on iOS…resolved it by going back to UIWebView - but I don’t see this as a fix.
On Android, I first compiled my app, and it worked fine on the device. However when I started messing with ionic cordova run android --device --livereload it somehow introduced the No Access-Control-Allow-Origin header issue.
But isn’t there a better solution to this? How can we test, on devices, with the newer cordova-plugin-ionic-webview if this is going to cause errors for external api/resouce calls?