Django设置允许跨域访问

安装django-cors-headers

ip install django-cors-headers

修改 setting.py

INSTALLED_APPS = [
    ......
    'corsheaders',
    ......
]

MIDDLEWARE = [
    ......
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    ......
]

CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_CREDENTIALS = True
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页