I am facing 'Access to XMLHttpRequest at 'URL' from origin 'http://localhost:8000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource' in javascript.
I have gone through many of the answers in the StackOverflow site. None of them worked for me. This request is to a remote server which I don't have control over it. I can only use the response from the site.
I have tried to add the
"headers": {
"Access-Control-Allow-Origin":"*"}
But this has changed nothing. I saw one option to add also.
dataType: "jsonp"
But dunno if these have any effects since I don't have any control over the response from the server.
This is what my request looks like.
$.ajax({
  type: "GET",
  dataType: "json",
  "headers": {
    "Access-Control-Allow-Origin":"*"
},
  url: URL,
  crossDomain: true,
  success: function(result) {
    console.log('success');
  },
  error: function(req, status, err) {
    console.log('Something went wrong', status, err);
  }
});
I read that we can access Only if the remote server supports JSONP or HTTP Access-Control headers.
If so what I can do in my case?
can anyone of you please help with this.
I have gone through the policy and checked some of the solutions.
http://anyorigin.com this is the only one that felt will work for me.But I am trying to access an internal domain.I felt It can introduce some security threat.
