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

前端 未结 5 2033
滥情空心
滥情空心 2020-12-09 10:25

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

5条回答
  •  臣服心动
    2020-12-09 11:14

    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.

提交回复
热议问题