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

前端 未结 5 2011
滥情空心
滥情空心 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 10:50

    this solution works for me and is based on an answer on a similar question How to add "Access-Control-Allow-Origin" headers to API Response in Ruby

    get '/' do
      response['Access-Control-Allow-Origin'] = '*'
      "asdf"  # return "asdf" 
    end
    

提交回复
热议问题