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  
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM