jpillora / xdomain

A pure JavaScript CORS alternative
https://jpillora.com/xdomain/
3.12k stars 270 forks source link

Unable to Set Value of the property 'addWithCredentials' #100

Closed throrin19 closed 10 years ago

throrin19 commented 10 years ago

Hi, I come to you for another problem. Now I have two different areas that need to communicate with each other (aaa.foo.com with bbb.bar.com) And I get this error on IE console :

Unable to Set Value of the property 'addWithCredentials' : Object is null or undefined
xdomain.js, line 996, character 2

This is my config on client side :

<!--[if lte IE 10]>
        <script type="text/javascript" src="js/libs/vendors/xdomain/dist/0.6/xdomain.js" slave="http://dapi.goomeo.com/v1.2/proxy"></script>
        <script type="text/javascript">
            xdomain.debug = true;
        </script>
        <![endif]-->

And this is my config on server side

<script src="js/libs/vendors/xdomain.min.js" master="https://dclients.goomeo.com"></script>
    <script src="js/libs/vendors/xdomain.js" master="http://dev.myeventsportal.com"></script>
    <script src="js/libs/vendors/xdomain.js" master="https://dev.myeventsportal.com"></script>
    <script src="js/libs/vendors/xdomain.js" master="http://local.myeventsportal.com"></script>
jpillora commented 10 years ago

https://github.com/jpillora/xdomain#using-multiple-masters-and-slaves

You should be using the second of the two snippets:

 <script src="//rawgit.com/jpillora/xdomain/gh-pages/dist/0.6/xdomain.min.js"></script>
  <script>
  xdomain.masters({
    'http://abc.example.com': '/api/*',
    //list more masters here...
  });
  </script>
throrin19 commented 10 years ago

Thanks. The key is the url of the accepted masters but the value is for ?

jpillora commented 10 years ago

See https://github.com/jpillora/xdomain#xdomainmastersmasters

throrin19 commented 10 years ago

OK :). Sorry ^^. So i can create this rules :

xdomain.masters({
      "http://a.example.com": "*",
 "http://b.example.com": "*"
    });
jpillora commented 10 years ago

Correct

On Mon, Jul 21, 2014 at 11:04 PM, Benjamin Besse notifications@github.com wrote:

OK :). Sorry ^^. So i can create this rules :

xdomain.masters({ "http://a.example.com": "", "http://b.example.com": "" });

— Reply to this email directly or view it on GitHub https://github.com/jpillora/xdomain/issues/100#issuecomment-49602408.

throrin19 commented 10 years ago

I have the same error on IE9

client side :

<!--[if lte IE 10]>
        <script type="text/javascript" src="js/libs/vendors/xdomain/dist/0.6/xdomain.js" slave="http://dapi.goomeo.com/v1.2/proxy"></script>
        <script type="text/javascript" src="js/libs/vendors/xdomain/dist/0.6/xdomain.js" slave="http://dapi.goomeo.com/v1.2/proxy"></script>
        <![endif]-->

server side :

    <script src="js/libs/vendors/xdomain.js"></script>
    <script type="text/javascript">
        xdomain.masters({
            'http://lclient.goomeo.com': '*',
            'http://*.myeventsportal.com': '*',
            'https://*.goomeo.com': '*',
            'https://*.myeventsportal.com': '*'
            //list more masters here...
        });
    </script>
jpillora commented 10 years ago

That's strange...

  1. Does the demo work for you in IE9?
  2. Does it still error with only 1 master?

On Mon, Jul 21, 2014 at 11:18 PM, Benjamin Besse notifications@github.com wrote:

I have the same error on IE9

— Reply to this email directly or view it on GitHub https://github.com/jpillora/xdomain/issues/100#issuecomment-49603724.

throrin19 commented 10 years ago

I have the error with one master. But i have not this error on same top domain (*.goomeo.com for my case) And the demo still works on my ie9

throrin19 commented 10 years ago

I try with :

 <script type="text/javascript">
        xdomain.slaves({
            'http://dev.myeventsportal.com': '/v1.2/proxy',
        });
    </script>

But i have the error 'xdomain is undefined'. Same error with xdomain.debug = true.

throrin19 commented 10 years ago

Ok, i find the problem. On this project, i include requireJS before xdomain. With this, xdoman is init ON AMD. I change javascript including order and it works. Thanks

jpillora commented 10 years ago

Ah I see, I'll mention that in the docs

On Tuesday, July 22, 2014, Benjamin Besse notifications@github.com wrote:

Ok, i find the problem. On this project, i include requireJS before xdomain. With this, xdoman is init ON AMD. I change javascript including order and it works. Thanks

— Reply to this email directly or view it on GitHub https://github.com/jpillora/xdomain/issues/100#issuecomment-49710455.