Forum Discussion

Warren_Brill's avatar
9 years ago

Access Control Issue

I have an API URL that works when pasted into a browser, but when scripted, does not.

Loading the page, the browser simply doesn't render anything. Chrome's "Inspect" returns:

"XMLHttpRequest cannot load ..."followed by the API URL (which we know is valid)

 

The error message goes on after the URL with

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://web.labs.hpecorp.net:8088' is therefore not allowed access.

The URL http://webs.lab ... is the calling page.

 

Why would the call work in a browser but not when scripted?

  • Hi Warren_Brill

     

    the issue here is that your script is likely violating the CORS policy. This is a security measure implemented in most browsers. I find that this article may help you understand the problem and what can be done to allow the call. Typically you will need the web server you are calling to return an appropriate Access-Control-Allow-Origin header that allows the call.

     

    Hope it helps,

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)

    Hi Warren_Brill

     

    the issue here is that your script is likely violating the CORS policy. This is a security measure implemented in most browsers. I find that this article may help you understand the problem and what can be done to allow the call. Typically you will need the web server you are calling to return an appropriate Access-Control-Allow-Origin header that allows the call.

     

    Hope it helps,