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

前端 未结 5 2025
滥情空心
滥情空心 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:13

    I did this on a server side, my file was called server.rb:

    before do
       content_type :json    
       headers 'Access-Control-Allow-Origin' => '*', 
                'Access-Control-Allow-Methods' => ['OPTIONS', 'GET', 'POST']  
    end
    

提交回复
热议问题