Websync 4 CORS issue

94 Views Asked by At

Hi,

I am working on a project to get feed from websync server. The server owner set Access-Control-Allow-Origin to * for testing purpose. However on trying to subscribe i am getting below error.

Access to XMLHttpRequest at 'http://IP/websync.ashx?token=11857997&src=js&AspxAutoDetectCookieSupport=1' from origin 'http://localhost:44371' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values 'http://localhost:44371, *', but only one is allowed.

I checked websync documentation and found that by default, WebSync responds to cross-origin resource sharing (CORS) requests by sending back appropriate values for the following headers.

WebSync Documentation

But still i don't know if i can fix the issue from client side.

Here is my sample javascript code

var client = new fm.websync.client("http://IP/websync.ashx");

client.connect({
  onSuccess: function(e)
  {
    writeLine("Connect success!");
  },
  onFailure: function(e)
  {
    writeLine("Connect failure.");
    writeLine(e.getException().message);
  },
  onStreamFailure: function(e)
   {
     writeLine("Stream failure.");
     writeLine(e.getException().message);
     writeLine("Reconnecting...");
   }
  });

var writeLine = function(text) {
var div = document.createElement('div');
div.innerHTML = text;
document.body.appendChild(div);};
0

There are 0 best solutions below