tornado nginx 同源(AccessControlAllowOrigin)错误处理记录

如果以下两个步骤操作完还是没有解决问题,可能是因为程序出了别的错误,因为后来的调试中不论出什么问题它都是会返回同源错误。。呵呵哒

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', '*')
原文地址:https://www.cnblogs.com/sunhuahuaa/p/8796875.html