We have 2 internal (intranet) Windows server on our network, only available to the local network. On server1 Spark is installed, where we can query Jabber information like so:
http://server1/plugins/presence/status?jid=username@jabbersrv&type=text
On server2 Spiceworks is installed, and I wrote a plugin to query that Jabber status like so:
xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", "http://server1/plugins/presence/status?jid=username@jabbersrv&type=text", false );
xmlHttp.send( null );
statusStr = xmlHttp.responseText;
But this code (on server2) is returning an error:
XMLHttpRequest cannot load http://server1/plugins/presence/status?jid=username@jabbersrv&type=text. Origin https://server2 is not allowed by Access-Control-Allow-Origin.
Why does this not work? I have some VB.net code that accomplishes this fine in the same environment:
Dim jbrStatus As New System.Net.WebClient
Dim userStatus As String = jbrStatus.DownloadString("http://server1/plugins/presence/status?jid=username@jabbersrv&type=text")
Neither are running Apache or the sort that I’m aware of, although Openfire is on server1. Should these 2 servers not inherently trust each other since they are internal (on the same domain)? What would be the best way of getting this working on a Windows domain & Windows servers?
I have tried adding server2 domain server as local admin on server1, but no luck.
It doesn’t matter whether they’re on the same network. If they have different domain names, XMLHttpRequests won’t work by default. You’ll need the server to send back certain headers, for Cross-Origin Resource Sharing. Note that this will only work on more recent browsers.