1

I have an Elasticsearch Node running and I can successfully recieve a Json response from the url: localhost:8882/rest/search/all using chrome.

However when I call it from react like this:

var config = {
          headers: {'Access-Control-Allow-Origin': '*', 
                    'Accept': 'application/json',
                    'Content-Type': 'application/json',
                    }
        };
axios.get('http://localhost:8882/rest/search/all',config).then(function (response) {...

I get a 403 error: Failed to load localhost:8882/rest/search/all; Response to preflight request doesn't pass access control check : No 'Access-Control-Allow-Origin' header is present on the requested resource

Will Barnwell
  • 3,729
  • 18
  • 33
HMZ
  • 79
  • 4
  • Please include any relevant text, in this case the error, in the question not as a screenshot. – Will Barnwell Oct 04 '17 at 00:53
  • thanks for the remark, i changed the image by text – HMZ Oct 04 '17 at 09:19
  • 1
    This error originates from Chrome actually, not from react or Elastic https://stackoverflow.com/questions/35588699/response-to-preflight-request-doesnt-pass-access-control-check – Will Barnwell Oct 04 '17 at 18:31
  • Thanks a lot Will Barnwell, it works when i disable web security in chrome with this : Open the start menu Type windows+R or open "Run" Execute the following command: chrome.exe --user-data-dir="C://Chrome dev session" --disable-web-security – HMZ Oct 04 '17 at 20:02

0 Answers0