freesound.js icon indicating copy to clipboard operation
freesound.js copied to clipboard

CORS errors

Open starakaj opened this issue 7 years ago • 1 comments

I'm having trouble using the API at all, due to CORS restrictions. All I tried to do was clone the repo, add my API key, and open the test.html page. But the result is just a bunch of errors like

XMLHttpRequest cannot load https://freesound.org/apiv2/search/text/?&page=1&filter=tag:tenuto%20durati…%2015.0]&sort=rating_desc&fields=id,name,url&query=violoncello&format=json. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

I am however able to use the api if I build a request using Postman, for what it's worth.

starakaj avatar May 15 '17 23:05 starakaj

You are probably opening the file locally, Browsers block any AJAX to external pages when a page is opened locally, just upload it to a webspace and take it from there. You may then still need to configure the CORS Headers, see w3 wiki

749 avatar Jul 22 '17 18:07 749