Question #1211
Updated by Alexander Watzinger over 4 years ago
*Update*: For handling Cross Origin Resource Sharing (CORS) and making cross-origin AJAX possible flask-cors was implemented: https://flask-cors.readthedocs.io/en/latest/.
*Original description*
Hi everyone!
For getting data into the thanados app I was trying to figure out how to access the API (from thanados.openatlas.eu) via javascript (from my localhost).
* 1st I set the API to public
* 2nd I tried to get one Json ld via jquery's getjson:
<pre>
$.getJSON( "https://thanados.openatlas.eu/api/0.1/entity/120290", function( data ) {
console.log(data)
});
</pre>
i get the following error:
<pre>
Access to XMLHttpRequest at 'https://thanados.openatlas.eu/api/0.1/entity/120290' from origin 'http://127.0.0.1:5000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
</pre>
If I execute the command from the console on the thanados.openatlas.eu website, it works.
I tried some suggestions from stackoverflow etc. but none did work to get the data from my localhost.
I wonder if the error is on my end or if we need to allow requests from other origins than thanados.openatlas.eu in the openatlas code.
Any help appreciated.
Thanks and best regards,
Stefan