3
我有一個在Tornado Web服務器上運行的Flask應用程序。我希望能夠從客戶端調用OPTIONS。我承認我不是100%,這是最好的辦法。我發現this,並將其放入我的燒瓶應用程序。這適用於除OPTIONS
之外的所有請求的開發服務器(僅適用於Flask)。當我坐在龍捲風的應用程序,我已將此添加到我的龍捲風應用:龍捲風/燒瓶沒有正確響應選項
class BaseHandler(tornado.web.RequestHandler):
def set_default_headers(self):
self.set_header("Access-Control-Allow-Origin", "*")
self.set_header("Access-Control-Allow-Credentials", "true")
self.set_header("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE,OPTIONS")
self.set_header("Access-Control-Allow-Headers", "Content-Type, Authorization, Accept")
這將返回所有請求,除了OPTIONS
以下標題:
Access-Control-Allow-Headers:CONTENT-TYPE, AUTHORIZATION, ACCEPT
Access-Control-Allow-Methods:HEAD, GET, PUT, POST, OPTIONS, DELETE
Access-Control-Allow-Origin:*
Access-Control-Max-Age:21600
Content-Length:3493
Content-Type:text/html; charset=utf-8
Server:TornadoServer/3.1
但OPTIONS
剛剛返回:
Content-Type: text/html; charset=utf-8
Content-Length: 0
Allow: HEAD, GET, PUT, POST, OPTIONS, DELETE
Server: TornadoServer/3.1
需要什麼才能將完整標題返回到OPTIONS
?