XMLHttpRequest is not allowed by Access-Control-Allow-Origin in .safariextz file

1.8k views Asked by At

I am getting following error in error console, facing this issue for many days, please help.

XMLHttpRequest cannot load "localhost Url". Origin https://mail.google.com is not allowed by Access-Control-Allow-Origin.

My purpose is to get an image from my local server and show this image in gmail compose.
This code is working fine in Firefox and Chrome but not with Safari Extension.

If I use Ninjakit to run this code, it works fine. But, if I create a .safariextz installer, I get this error. It's not even going inside an onload function.

Code is:

GM_xmlhttpRequest({ 
  method: 'GET', 
  url: validURL, // localhost Url 
  headers: { 
    'crossDomain':'true', 
    'Accept': 'application/json', 
    'cache-control':'no-cache, no-store, max-age=0, must-revalidate', 
    'pragma':'no-cache', 
  }, 
  onload: function(responseDetails) { 
    var res = responseDetails.responseText; 
  } 
});
0

There are 0 answers