0

I have a website hosted in ColdFusion Server that do a http post to my application hosted in Azure Server. I set a CROS-Orign exception in my Azure server that allows request from the ColdFusion Server. Everything is working fine when I run it by my computer (not localhost. The coldfusion server). However, if someone else tries it using another computer, it returns:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at azureServer

Is it possible? How can it knows my computer?

My AJAX request:

data = {
   var1: 10,
   var2: "ABC"
};

$.ajax({
  url: "https://myAzureServer",
  headers: {
    'Access-Control-Allow-Origin': '*'
  },
  type: "POST",
  dataType: 'json',
  data: data,
  success: function(result) {
    if (result) {
      console.debug("Success");
    } else {
      console.debug("Error after running");
      console.debug(result);
    }
  },
  error: function(xhr, status, p3, p4) {
    var err = "Error " + " " + status + " " + p3;
    if (xhr.responseText && xhr.responseText[0] == "{")
      err = JSON.parse(xhr.responseText).message;
    console.debug("error");
    console.debug(err);
  }
});
rrk
  • 15,677
  • 4
  • 29
  • 45
Max Boy
  • 317
  • 6
  • 21
  • 1
    Best advice I can give is to include `` and flush your cache. – TRose Feb 06 '18 at 00:39
  • But Coldfusion is requesting data. Should the allow-origin be only in the server that receives the request? – Max Boy Feb 06 '18 at 01:01
  • I have a site where a ColdFusion page requests data similarly from an Amazon S3 bucket. That was my magic bullet to solve a problem I had. Unless you have access to a setting (similar to an S3 Bucket policy) where you can tell your server which requests to accept... that's the limit of my experience on the topic. https://stackoverflow.com/questions/45250974/saving-an-image-from-a-canvas-using-todataurl-tainted-canvas-error-workaroun – TRose Feb 06 '18 at 01:50
  • It is odd because from my computer it is working fine, but using another computer it doesn't work. – Max Boy Feb 06 '18 at 14:00
  • In addition to the response supplied by @TRose, you should also change your ajax call to `dataType: 'jsonp'` instead of `dataType: 'json'`. – user9263373 Feb 06 '18 at 15:14
  • Isn't jsonp only for 'GET', not 'POST'? – Max Boy Feb 07 '18 at 19:56

0 Answers0