django 跨域访问

1.安装
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 on 2021-09-30 14:20  兔子二  阅读(25)  评论(0编辑  收藏  举报

导航