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


#1

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!


#2

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


#3

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


#4

No answers anywhere… =(


#5

Somebody just posted here.


#6

Did someone found a solution for it?

Thx


#7

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


#8

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


#9

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.


#10

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


#11

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