JSPM

x-domain-object-proxy

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q17920F
  • License MIT

Helps older versions of IE make XDomainObject requests from HTTP protocol pages to HTTPS

Package Exports

  • x-domain-object-proxy

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (x-domain-object-proxy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

X-Domain-Object-Proxy

Package for web applications which wish to support IE 8-9 and need Cross Domain Request Support, specifically from HTTP pages to HTTPS.

Motivation:

The limitations of XDR functionality in IE 8 and 9 are described in this blog post: http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx. This library intends to provide the workaround for point 7. Please be aware of the other limitations and requirements on the server side around headers and response types as mentioned in the blog post, if you intend to support IE 8 and 9.

Installation:

npm install --save x-domain-object-proxy

Proxy:

You will need to be able to set up an HTTPS folder on your web server and serve a html page which loads the XDomainObjectProxy.proxy.js file and starts the proxy. A sample html file might look something like this:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
    <title>proxy</title>
  <script type="text/javascript" src="http://mydomain.com/scripts/XDomainObjectProxy.proxy.js"></script></head>
  <body>
    <script>XDomainObjectProxy.proxy.start();</script>
  </body>
</html>

We have a template src/proxy/proxy.ejs which you can incorpate into your webpack build, or use your own template

Client:

You will then use the request helper as such:

// Either ES6 Import 
import {create} from 'XDomainObjectProxy.client'
var client = create();

// Or as a global object from using <script> tags
var client = XDomainObjectProxy.client.create('https://localhost:8081/proxy.html');

/**
 * some other code ...
 */

var options = {
  location: 'https://api.nasa.gov/planetary',
  path: '/apod',
  qs: {
    'api_key': 'DEMO_KEY'
  }
}
client.sendRequest(options).then(function (data) {
  console.log('data returned', data);
}, function (err) {
  console.log('error', err);
});