django基于cors做跨域处理
背景知识: 跨域相关与cors策略
1.安装django-cors-headers
pip install django-cors-headers
2.settings.py配置
INSTALLED_APPS = [ ...... 'corsheaders', ...... ] MIDDLEWARE = [ ...... 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', ...... ] CORS_ORIGIN_ALLOW_ALL = True CORS_ALLOW_CREDENTIALS = True