CORS in DRF

什么是跨源资源共享(CORS)


设定跨源资源共享(CORS)

# 需要安装
pip install django-cors-headers
 
# settings.py
# 允许所有域名
CORS_ALLOW_ALL_ORIGINS = True
 
CORS_ALLOWED_ORIGINS = [
    "http://localhost:3000",
    "http://127.0.0.1:3000",
]