cors中间件

cors中间件

from django.utils.deprecation import MiddlewareMixin

class CorsMiddleWare(MiddlewareMixin):


    def process_response(self,request,response):

        if request.method=="OPTIONS":
            response["Access-Control-Allow-Methods"] = "GET"

        response["Access-Control-Allow-Origin"] = "*"
        response["Access-Control-Allow-Headers"] = "Content-Type,Authorization"


        return response

 

posted @ 2020-06-04 18:58  虫洞小鳗鱼  阅读(237)  评论(0编辑  收藏  举报