python基础-跨域问题

跨域

    -- 浏览器的同源策略 阻止ajax请求 不阻止src请求
    -- jsonp
        -- 我们利用src发送请求
    -- core
        -- class MyCore(MiddlewareMixin):
            def process_response(self, request, response):
                response['Access-Control-Allow-Origin'] = "*"
                if request.method == "OPTIONS":
                    # 复杂请求 预检
                    response['Access-Control-Allow-Headers'] = "Content-Type"
                    response['Access-Control-Allow-Methods'] = "POST, DELETE, PUT"
                return response

 

posted @ 2018-09-25 19:38  神秘嘉宾7m  阅读(80)  评论(0编辑  收藏  举报