标签:django 还需 ons content bsp cal div middle span
首先需要定义一个中间件
from django.utils.deprecation import MiddlewareMixin class CorsMiddleware(MiddlewareMixin): def process_response(self,request,response): response["Access-Control-Allow-Headers"] = "Content-Type" #get请求 response["Access-Control-Allow-Origin"]="http://localhost:8081" #post请求 return response
还需要在setting中的MIDDLEWARE中注册中间件
"api.utils.middleware.CorsMiddleware"
标签:django 还需 ons content bsp cal div middle span
原文地址:https://www.cnblogs.com/qq631243523/p/10139675.html