pip install django-cors-headers
INSTALLED_APPS = [
......
'corsheaders',
......
]
MIDDLEWARE = [
......
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
......
]
#在settings中 任意位置写入下面代码
CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_CREDENTIALS = True
如此,django后端配置就完成了,快去试试吧