Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sinatra access-control-allow-origin for sinatra public folder

Tags:

html

sinatra

How do I set up Sinatra so that static files in the public folder are returned with the response Access-Control-Allow-Origin = "*" ?

like image 425
peter Avatar asked Aug 18 '11 15:08

peter


People also ask

Is Access-Control allow Origin * Insecure?

The 'Access-Control-Allow-Origin' header is insecure when set to '*' or null, as it allows any domain to perform cross-domain requests and read responses.


1 Answers

Have a look at this question here: Sinatra OPTIONS HTTP Verb. It's implemented in sinatra now so you don't have to hack around it.

If that doesn't help take a look at this blog post: Cross Origin Resource Sharing with Sinatra, and its repo at github: sinatra-corss_origin

Although the simplest way to do it should work just by adding this:

response['Access-Control-Allow-Origin'] = 'http://whatever.org'

before the return value in your route.

like image 197
scable Avatar answered Sep 25 '22 10:09

scable