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

 

posted @ 2018-12-10 13:39  似是故人来~  阅读(710)  评论(0编辑  收藏  举报