更新时间:2022-11-23 08:22:43
请看这里: Sinatra OPTIONS HTTP动词。它现在在sinatra中实现了,所以你不必在它周围进行破解。
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.
如果这无助于看看这篇博文:与Sinatra的跨源资源共享及其在github的回购: sinatra-corss_origin
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.