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

 

上一篇:【跨域CORS】的出现及解决办法


下一篇:ajax、axios请求之同源策略与CORS