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  
 
posted @ 2017-06-29 15:56  汪汪小喵咪  阅读(5107)  评论(0编辑  收藏  举报