django 跨域
使用vue axios报错
has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header
django 添加中间件
附上代码:
from django.utils.deprecation import MiddlewareMixin class AccessControl(MiddlewareMixin): def process_response(self, request, response): print(response) # response['Access-Control-Allow'] = '*' response['Access-Control-Allow-Headers'] = '*' response['Access-Control-Allow-Origin'] = '*' # response['Allow'] = 'GET, HEAD, OPTIONS, POST' print(response) return response