跨域请求问题的处理

前些天做某个框架demo时,跨域调用了api,然后出错了

  • has been blocked by CORS policy

搜了一下原来是浏览器限制:https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Access_control_CORS

随即在后端做了修改

import web

urls = (
    '/', 'Index'
)

class Index:
    def GET(self):
        web.header('content-type','text/json')
        web.header('Access-Control-Allow-Origin','*')
        ...

搞定

posted @ 2020-03-03 11:06  zw1027  阅读(133)  评论(1编辑  收藏  举报