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  
 
相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息