安装django-cors-headers
python -m pip install django-cors-headers
在#setting.py 下添加如下代码
INSTALLED_APPS = [
    ...,
    "corsheaders",
    ...,
]

MIDDLEWARE = [
    ...,
    "corsheaders.middleware.CorsMiddleware",   #尽量放在最上面
    "django.middleware.common.CommonMiddleware",
    ...,
]
 ...
CORS_ORIGIN_ALLOW_ALL = True # 新增这一句

  

 
 
posted on 2023-02-15 15:29  车仔面XO  阅读(11)  评论(0编辑  收藏  举报