Reputation: 978
I am building an application using ionic framework with backend written in Django.
When i try to do testing i am getting the following error message
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8000/api/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
I saw some documentation and it was mentioned that i need to add proxies under ionic.config.json so i added the proxies it look something like this
"proxies":[
{
"path":"/api",
"proxyUrl": "http://localhost:8000/api"
}
]
Thanks in Advance
Upvotes: 2
Views: 894
Reputation: 1
You can use this library
pip install django-cors-headers
INSTALLED_APPS = (
...
'corsheaders',
...
)
MIDDLEWARE = [ # Or MIDDLEWARE_CLASSES on Django < 1.10
...
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
...
]
Upvotes: 0