Funny Origin: ionic://localhost CORS header on ios

Hi.

I have just upgraded an app to ionic4. As far as I understand, a new webview is used in Cordova for ios which enforces CORS. So far so good.

I was surprised though that ios is sending:

Origin: ionic://localhost

I had expected http://localhost. It’s not really a problem since I have control over the server and added it to the allowed origins. I am wondering however what the reason for this url is? I have ran the same app on platforms android and browser. And there it sends http://localhost as expected.

Here is a capture of the traffic:

Hi @nharrer,

From what I understood when talking with Julio from the Ionic team, is that in order to remove the internal web server iOS needed a custom scheme to access local files (couldn’t use http) and Android didn’t, hence the difference.

All the different origins are documented in the CORS Errors docs page, but as long as you allow this origin and reflect it back you shouldn’t have any problem.

Best,
Rodrigo

1 Like

we cant add origin like ionic://localhost to the 3rd party azure api.so then what is the best workaround?

4 Likes