{"id":15383469,"url":"https://github.com/sneas/ionic-native-http-connection-backend","last_synced_at":"2025-04-05T09:10:40.653Z","repository":{"id":23025440,"uuid":"97965788","full_name":"sneas/ionic-native-http-connection-backend","owner":"sneas","description":"A solution to CORS issues with Ionic and iOS","archived":false,"fork":false,"pushed_at":"2023-01-09T11:46:40.000Z","size":3002,"stargazers_count":160,"open_issues_count":4,"forks_count":48,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-29T08:06:46.918Z","etag":null,"topics":["angular","ionic","wkwebview"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sneas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-21T16:08:27.000Z","updated_at":"2025-02-22T18:52:47.000Z","dependencies_parsed_at":"2023-01-13T22:38:07.181Z","dependency_job_id":null,"html_url":"https://github.com/sneas/ionic-native-http-connection-backend","commit_stats":null,"previous_names":[],"tags_count":56,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sneas%2Fionic-native-http-connection-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sneas%2Fionic-native-http-connection-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sneas%2Fionic-native-http-connection-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sneas%2Fionic-native-http-connection-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sneas","download_url":"https://codeload.github.com/sneas/ionic-native-http-connection-backend/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247312085,"owners_count":20918344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","ionic","wkwebview"],"created_at":"2024-10-01T14:37:49.915Z","updated_at":"2025-04-05T09:10:40.620Z","avatar_url":"https://github.com/sneas.png","language":"TypeScript","readme":"# ionic-native-http-connection-backend\n\n[![version](https://img.shields.io/npm/v/ionic-native-http-connection-backend.svg?style=flat-square)](http://npm.im/ionic-native-http-connection-backend)\n[![MIT License](https://img.shields.io/npm/l/component-library.svg?style=flat-square)](http://opensource.org/licenses/MIT)\n\nThis library adds `@awesome-cordova-plugins/http` (when available) as a connection backend to Angular's `Http` and `HttpClient`\n\n## Motivation\n\nNow 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`](https://github.com/ionic-team/cordova-plugin-ionic-webview) \n(and Cordova offers it via their [`cordova-plugin-wkwebview-engine`](https://github.com/apache/cordova-plugin-wkwebview-engine)). That causes requests that used to work just fine to fail with [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) errors.\n\nThe real solution of course is to fix the CORS issues server side - but this may not be possible with e.g. 3rd party APIs.\n\nEven though there is a way to solve CORS issues without changing server's response header by using [`@awesome-cordova-plugins/http`](https://ionicframework.com/docs/native/http/), this only works on device and doesn't provide all the power of Angular's `Http` and `HttpClient`.\n\n## How it works\n\n- The library provides a `HttpBackend` interface for Angular's `HttpClient`\n- This `HttpBackend` interface tries to use `@awesome-cordova-plugins/http` whenever it is possible (= on device with installed plugin)\n- If `HttpBackend` finds it impossible to use `@awesome-cordova-plugins/http`, it falls back to standard Angular code (`HttpXhrBackend`, which uses `XmlHttpRequest`)\n\nThis strategy allows developers to use Angular's `HttpClient` transparently in both environments: Browser and Device.\n\n## Installation\n\n```bash\nnpm install --save ionic-native-http-connection-backend\n```\n\nThen follow instructions at https://ionicframework.com/docs/native/http/#installation\n\n## Usage\n\nAdd `NativeHttpModule`, `NativeHttpBackend` and `NativeHttpFallback` into the application's module\n\n```typescript\nimport { NgModule } from '@angular/core';\nimport { HttpBackend, HttpXhrBackend } from '@angular/common/http';\nimport { NativeHttpModule, NativeHttpBackend, NativeHttpFallback } from 'ionic-native-http-connection-backend';\nimport { Platform } from '@ionic/angular';\n\n@NgModule({\n    declarations: [],\n    imports: [\n        NativeHttpModule\n    ],\n    bootstrap: [],\n    entryComponents: [],\n    providers: [\n        {provide: HttpBackend, useClass: NativeHttpFallback, deps: [Platform, NativeHttpBackend, HttpXhrBackend]},\n    ],\n})\nexport class AppModule {\n}\n```\n\n## Contributing\n\nContributing guidelines could be found in [CONTRIBUTING.md](CONTRIBUTING.md)\n\n## Troubleshooting\n\n[TROUBLESHOOTING.md](TROUBLESHOOTING.md)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsneas%2Fionic-native-http-connection-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsneas%2Fionic-native-http-connection-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsneas%2Fionic-native-http-connection-backend/lists"}