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