前些天做某个框架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','*')
...
搞定