Giter Site home page Giter Site logo

cordova-plugin-ios-xhr's Introduction

cordova-plugin-ios-xhr

cordova-ios 6+ File XHR Plugin

About

Originally, this plugin was a merge of two other plugins, and made compatible for cordova-ios 6+.

cordova-plugin-wkwebview-file-xhr

cordova-plugin-wkwebviewxhrfix

It's been since remodified and the code from TheMattRay has now been entirely removed. It is kept here as original reference. This could be turned into a PR to cordova-plugin-wkwebview-file-xhr, if time allows it, or if anybody wants to go at it! All credits go to Oracle.

Install

Install from github master

 cordova plugin add https://github.com/rubnogueira/cordova-plugin-ios-xhr

Uninstall

 cordova plugin rm cordova-plugin-ios-xhr

Preferences

 <preference name="NativeXHRLogging" value="full|none" />
 <preference name="AllowUntrustedCerts"  value="true|false" />
 <preference name="InterceptRemoteRequests" value="all|secureOnly|none" />
 <preference name="allowFileAccessFromFileURLs" value="true|false" />
 <preference name="allowUniversalAccessFromFileURLs" value="true|false" />

Description

The default behavior of WKWebView is to raise a cross origin exception when loading files from the main bundle using the file protocol - "file://". This plugin works around this shortcoming by loading files via native code if the web view's current location has "file" protocol and the target URL passed to the open method of the XMLHttpRequest is relative. As a security measure, the plugin verifies that the standardized path of the target URL is within the "www" folder of the application's main bundle or in the /Library path of the application data directory.

Since the application's starting page is loaded from the device's file system, all XHR requests to remote endpoints are considered cross origin. For such requests, WKWebView specifies "null" as the value of the Origin header, which will be rejected by endpoints that are configured to disallow requests from the null origin. This plugin works around that issue by handling all remote requests at the native layer where the origin header will be excluded

Fixes local file access via XHR with WKWebView

CustomUserAgent is only set for XHR requests and does not override cordova's OverrideUserAgent

cordova-plugin-ios-xhr's People

Contributors

globules-io avatar mike-nelson avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.