Django"Access-Control-Allow-Origin"

具体报错方式:XMLHttpRequest cannot load http://127.0.0.1:8000/api/infos. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.30.59:8000' is therefore not allowed access
Django框架Restangular发送API请求,跨源资源共享的问题。
解决方法:
 
pip install django-cors-headers
INSTALLED_APPS = (
...
'corsheaders',   
...
)
MIDDLEWARE_CLASSES
= (
...   
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',   
...
)
 
CORS_ORIGIN_ALLOW_ALL
= True  
 
原文地址:https://www.cnblogs.com/allan-king/p/7094954.html