That is correct. The Ionic Webview plugin 3.x uses ionic:// as protocol because it needs a custom scheme in order to serve local files.
You can find all the different origins at the CORS Errors page on the Ionic docs.
I saw somewhere that a Googler was suggesting to use a special string as origin in the Firebase console but I can’t find it now I’ll post here if I do.
It took me a while, but I indeed found the documentation specifying that it’s ionic:// that’s being used now, with WKWebView.
Firebase auth does a client side check on the location.protocol, which is ionic://, therefore it won’t even let me connect to firebase.
I’m now trying to bypass firebase’s google signin and do the sign in to google directly.
The plan is then to grab to token and pass it to firebase.
No idea of this is going to work, but i’ll post the solution here if it does.
I haven’t found where this can be configured in Google Cloud Console.
It’s definitely not in firebase, as it’s only expecting the domain name, not the protocol.
i’ll keep looking, but let me know if you find the page
ah ok, misread it.
I understand what to do; that is, set the referrer to __ionic_url__/localhost
But can’t quite figure out a way to change the referrer yet.
Looking into it
I’m not sure. I tried entering __ionic_url__/localhost in the Firebase console > Authentication > Authorised domains, but it doesn’t pass the validation. Maybe adding this origin from the Google Cloud APIs console may work, but I don’t know how where to find it there.
For anyone following this thread, it looks like a similar issue exists using API’s that are fronted by Azure API Manager.
The CORS policy in APIM only allows origins beginning with “http” or “https”
So it works for the app in a browser, and on Android (Origin=http://localhost) but iOS (Origin=ionic://localhost) cannot even be configured. It errors with
One or more fields contain incorrect values:
Error in element ‘cors’ on line 21, column 18: Origin must be a valid URL consisting of scheme, host, and port only
So looks like Ionic as a mobile web dev technology cannot be used OOTB with an Azure API Manager managed backend? … still looking for a workaround in APIM but it looks like changing the origin from the ionic side will have to be done using the documented https://ionicframework.com/docs/native/http/ workaround… blurk
If anyone else is trying to use ionic with Azure APIm - you can up vote the suggestion for custom url schemes here.
Would be better if ionic could do something to resolve the underlying problem and let the scheme be specified or just use https://localhost on ios like they do for android…
@aholland Hi , Is this the best workaround for the moment?currently i’m using third party azure api as backend and i get this cors error in ios bcz of this ionic://localhost.
Hi @nalaka-au yes this mitigates the CORS issue as it’s not using a browser based http client and requires minimal changes to existing code.
Azure API Management team have triaged this and may add support for custom schemes eventually
You could vote it up - but in the meantime I think Dmitry’s solution is a good one.