seven1m / bible_api

Ruby web app that serves JSON API for open and public domain bibles
https://bible-api.com
MIT License
569 stars 104 forks source link

Consider adding Access-Control-Allow-Origin header to API response #26

Closed nevnein closed 5 years ago

nevnein commented 6 years ago

When trying to GET a resource with the new fetch() API, the access is blocked due to CORS policy:

Failed to load https://bible-api.com/Mark%203:10?translation=rccv: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https:/xxx.xxxxx.xx' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Please consider adding Access-Control-Allow-Origin: * header to the response.

I am not familiar with Sinatra, else I would've opened a pull request myself; anyway, I found this article which may prove useful: Adding CORS configuration to a Sinatra app Thank you for your time

seven1m commented 6 years ago

I'll consider it!!

We do provide jsonp API that you can use cross-domain: http://bible-api.com/john+3:16?callback=whatever

MasterOfTheTiger commented 6 years ago

I can't get it to work. I keep getting the same error. Can someone help?

duncanmcclean commented 6 years ago

Yeh, I'm getting the same error here 😢

seven1m commented 5 years ago

This took me over a year 😭 but it's finally done!

MasterOfTheTiger commented 5 years ago

@seven1m Woo hoo! Thank you so much for this! I might finally use this API for something. :heart:

tim-hub commented 1 year ago

I recently got the CORS as as well.


Acess to fetch at 'https://bible-api.com/John+1:1?translation=web' from origin 'xxx' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
seven1m commented 1 year ago

@tim-hub I added a new issue for that: #86