jeudi 7 juillet 2016

Ruby on Rails Ajax Call on Wiki API returns CORS issue

I'm testing out an api endpoint from wikipedia:

http://ift.tt/1KyK6Y3

using an Ajax call on Ruby on Rails. The tutorial suggests using coffeescript which is what I'm using.

$.ajax 'http://ift.tt/1KyK6Y3',
type: 'GET'
format: 'json'
origin: 'http://ift.tt/1keYC5E'
success: (data, textStatus, jqXHR) ->
    console.log(data);

All I'm getting is this error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://ift.tt/1KyK6Y3. (Reason: CORS header 'Access-Control-Allow-Origin' missing).

I've researched on the issue and tried rack-cors and then configured it but so far, I'm still getting the CORS issue and not able to retrieve the api endpoint result. Can anyone help?

Aucun commentaire:

Enregistrer un commentaire