How to config xginx api server to accept requests from android/ios apps?
-
I’m developing a web app since a while. Now we’re tring to run it as a mobile app (android only in this moment).
We stopped becase all api calls from mobile app is being blocked because of cors policy.
I’ve not a clear idea of how cors headers and preflight options calls works.
Anyway, I ask you kindly if there is something from quasar app code side to be done to be able to make api calls.
I never faced problem in calling apis using native java android apps. I stupidly thinked it wil not be a problem in a quasar cordova mode app.
Please, help me to understand what should I do to allow my app to make api calls.
-
@realtebo cors is a server side setup, use some google fu, many resources out there about it.
-
I understand it’s most server side. But I cannot understand why quasar app has this problems while native java android app has not problem doing requests to web services.
-
@realtebo said in How to config xginx api server to accept requests from android/ios apps?:
I understand it’s most server side. But I cannot understand why quasar app has this problems while native java android app has not problem doing requests to web services.
probably because java xmlhttp transport is less secure. CORS is a browser thing and it may or may not be implemented. If it is, then it needs supporting server. It is good, that CORS is implemented. Very good.
-
What qyloxe said, unless you use a native http client (dunno if cordova has, i use d to use retrofit owhen i was doing native android) you will have to set cors in your server since cordova is runnning on a webview which uses browser technology. Some reading https://ionicframework.com/docs/troubleshooting/cors
-
We resolvede server side on development using a proxy bypass with origin rewrite. For production server we’re unable to enable origin ‘*’ so we’ll try to add a reverse proxy or a pass through proxy like done in development.
Thanks