
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
ionic-native-http-connection-backend
Advanced tools
A solution to CORS problem with Ionic and WKWebView
This library adds @awesome-cordova-plugins/http
(when available) as a connection backend to Angular's Http
and HttpClient
Now that Apple promotes/requires the use of WKWebView
instead of the deprecated UIWebView
, Ionic has switched newly created apps over via their cordova-plugin-ionic-webview
(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 @awesome-cordova-plugins/http
, this only works on device and doesn't provide all the power of Angular's Http
and HttpClient
.
HttpBackend
interface for Angular's HttpClient
HttpBackend
interface tries to use @awesome-cordova-plugins/http
whenever it is possible (= on device with installed plugin)HttpBackend
finds it impossible to use @awesome-cordova-plugins/http
, it falls back to standard Angular code (HttpXhrBackend
, which uses XmlHttpRequest
)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
Add NativeHttpModule
, NativeHttpBackend
and NativeHttpFallback
into the application's module
import { NgModule } from '@angular/core';
import { HttpBackend, HttpXhrBackend } from '@angular/common/http';
import { NativeHttpModule, NativeHttpBackend, NativeHttpFallback } from 'ionic-native-http-connection-backend';
import { Platform } from '@ionic/angular';
@NgModule({
declarations: [],
imports: [
NativeHttpModule
],
bootstrap: [],
entryComponents: [],
providers: [
{provide: HttpBackend, useClass: NativeHttpFallback, deps: [Platform, NativeHttpBackend, HttpXhrBackend]},
],
})
export class AppModule {
}
Contributing guidelines could be found in CONTRIBUTING.md
FAQs
A solution to CORS problem with Ionic and WKWebView
We found that ionic-native-http-connection-backend demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.