Reputation: 8855
I've got an XML file on my server, and my partners have to access it via a javascript I'm coding.
It's working perfectly in local, but as soon as I do :
xmlDoc.async=false;
xmlDoc.load("/export/export.xml");
to
xmlDoc.load("http://www.something.com/export/export.xml");
It stopped working. I know that it's to avoid XSS attack, but there is no point in my case to develop that JS script if they cannot access to my XML file.
So, how to bypass such a limitation?
Upvotes: 2
Views: 1885
Reputation: 706
Here are some workarounds for the SOP (Same Origin Policy) problem here. The post is about jQuery, but the concepts are the same:
Upvotes: 0
Reputation: 250812
I use a proxy on my domain to obtain the information. This can be any server-side script that goes and gets the information from the remote server - that way, all requests are to my local server proxy page.
Upvotes: 1
Reputation: 526493
Depending on the need, one option would be to fully encapsulate everything coming from your site in an independent frame which is loaded from your site, thus making the page doing the loading match the server properly.
Another option would be for the partners to run a server-side script on their server that can fetch the XML file and then pass it through to the client so that it "appears" to be hosted on their server.
There's no way to bypass it on the client side; if there were it would defeat the purpose of restricting it in the first place.
Upvotes: 1