Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cross domain XMLHttprequest

Here is my situation:

I have a Webserver machine, Client machine, and a third machine running some program that listens for XMLHttpRequests.

Client accesses the Webserver from the Client machine, makes some changes, and then clicks on'Save'. At this point, data is being sent back to the Webserver and to the Third machine. All of this is being done using Javascript and XMLHttpRequest object.

The post to the Webserver works fine, however post to the Third machine does not work, since it had a different IP/domain.

How can I make this work? Client machine -> Third machine does not work, because its on a different domain Webserver machine -> Third machine does not work, because of firewall issues

Any ideas are greatly appreciated!

like image 296
screenshot345 Avatar asked Jun 29 '10 19:06

screenshot345


1 Answers

What you're running into is the Same origin policy, not firewall issues.

If the machines share a top-level domain, you can set their document.domain properties to match:

Two sites sharing a common top-level domain may opt to communicate despite failing the "same host" check by mutually setting their respective document.domain DOM property to the same qualified, right-hand fragment of their current host name.

Otherwise, you may need to setup your first host to proxy the request to the other host.

like image 93
Ben S Avatar answered Oct 04 '22 10:10

Ben S