This library adds
@ionic-native/http (when available) as a connection backend to Angular's
Now that Apple promotes/requires the use of
WKWebView instead of the deprecated
UIWebView, Ionic has switched newly created apps over via their
(and Cordova offers it via their
cordova-plugin-wkwebview-engine). That causes requests that used to work just fine to fail with CORS errors.
The real solution of course is to fix the CORS issues server side - but this may not be possible with e.g. 3rd party APIs.
Even though there is a way to solve CORS issues without changing server's response header by using
@ionic-native/http, this only works on device and doesn't provide all the power of Angular's
How it works
- The library provides a
HttpBackendinterface for Angular's
HttpBackendinterface tries to use
@ionic-native/httpwhenever it is possible (= on device with installed plugin)
HttpBackendfinds it impossible to use
@ionic-native/http, it falls back to standard Angular code (
HttpXhrBackend, which uses
This strategy allows developers to use Angular's
HttpClient transparently in both environments: Browser and Device.
npm install --save ionic-native-http-connection-backend
Then follow instructions at https://ionicframework.com/docs/native/http/#installation
NativeHttpFallback into the application's module
Contributing guidelines could be found in CONTRIBUTING.md