Native app is sending header Origin:file:// which causes problems

Hello!

I have started building simple Todo app in Ionic 1 and I discovered a problem with Origin header. (CORS related)

If i run

ionic serve

everything works fine in browser and i can make requests to my REST API on apache(tomcat). But when build my app for android or even in ionic viewer, all requests fail. Using a chrome debugger I managed to locate the problem.

Native app sends header

Origin: file://

which causes my server to deny requests. Seems to me that it should send correct Origin header with host. Screenshot with more details is attached below.

What can I do about that?

Found related topic here: http://stackoverflow.com/questions/25914071/cors-cordova-angularjs-http-and-file-confusion

EDIT: Problem occurs when post, if I run ionic starter (tabs) template with only $http.post('http://myapp.com/apiv1/device') added to controller.

Thanks in advance!

Same problem anyone? It is really bugging me. =)

I am facing the same problem. Found any solution to this?

No answers anywhere… =(

Somebody just posted here.

Did someone found a solution for it?

Thx

Is your server tomcat? https://bz.apache.org/bugzilla/show_bug.cgi?id=60008

Hi, honestly it is not our service, and we can not ask to the maintainer this information. And also they answer checking the origin is a requested by RFC. So we have no way to resolve this on server side.

This is very frustrating

If ou don’t get a better answer: Just put a “proxy” service in between that fixes the CORS stuff if you don’t own the API.

Putting a proxy service in the middle would obviously work, and would be a solution but IMO it would be a bad workaround for something what should be handled from cordova.
Perhaps we can resolve it with native HTTP

I am also facing same issue, it seems a big issue with the ionic