如果以下两个步骤操作完还是没有解决问题,可能是因为程序出了别的错误,因为后来的调试中不论出什么问题它都是会返回同源错误。。呵呵哒
1.在nginx.conf里配置server,在location里添加红色字部分,* 表示所有域皆可访问:
location / { root html; index index.html index.htm; add_header 'Access-Control-Allow-Origin' *; }
2.tornado 中在需要访问的方法中加入set_header,比如get:
def get(self): self.set_header('Access-Control-Allow-Origin', '*')
本文介绍了解决跨域问题的两种方法:一是通过在nginx.conf中配置server,添加Access-Control-Allow-Origin头允许所有域访问;二是通过在Tornado框架中需要访问的方法中加入set_header设置Access-Control-Allow-Origin头。
3772

被折叠的 条评论
为什么被折叠?



