jpillora / xdomain

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

Only works on first load #138

Closed ghost closed 9 years ago

ghost commented 9 years ago

Hi,

I implemented xdomain with an API created on google AppEngine that works with Cloud Endpoints.

The application that uses this API is on another server and is based on the AngularJS framework, therefore cross domain is an issue, but only for IE9, on other browsers it works properly. When implementing xdomain the first time a request is made when loading the page it works properly, but when changing to another page and another request is made the application gets stuck where xdomain on the server gives the following error:

"Invalid operand to 'instanceof': Function expected", I believe is on the sendPostMessage method.

When enabling the debug on the client it gives the following logs:

xdomain (http://www.example.net): proxying request to slave: 'https://www.abc.example.com' xdomain (http://www.example.net): new socket: xdomain-ff383eb8

And on the server no logs are created.

I have previously implemented on the client app with another API that is created with C# ASPX and it works perfectly.

jpillora commented 9 years ago

Interesting, could make a demo page using jsfiddle/plunkr which reproduces this? (Please use unminified versions of all included scripts)

If you need a domain to test with, http://echo.jpillora.com simply echoes your requests metadata, and it also has a http://echo.jpillora.com/proxy.html.

ghost commented 9 years ago

Hi,

So I found what the problem was actually, and it is not a problem with the plugin. I am using angularjs for my project and I didn't realize at first the problem was the iframe used by xdomain was being removed. Not all of my routes change the whole body html so it was not at first visible that was the problem.

Is there a way to rebind the iframe calling another method?

jpillora commented 9 years ago

Not sure what you mean, can you not replace the body? For example, maybe you could make a container div for your app, so when that clears, it won't remove the iframe

On Saturday, March 14, 2015, danielarita notifications@github.com wrote:

Hi,

So I found what the problem was actually, and it is not a problem with the plugin. I am using angularjs for my project and I didn't realize at first the problem was the iframe used by xdomain was being removed. Not all of my routes change the whole body html so it was not at first visible that was the problem.

Is there a way to rebind the iframe calling another method?

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

jpillora commented 9 years ago

Reopen if still an issue