0👍
I encountered the same problem. Here’s how I solved it:
- Install django-cors-headers by executing the following in your terminal:
pip install django-cors-headers
- In your settings.py file, insert the following:
MIDDLEWARE = [
...,
"corsheaders.middleware.CorsMiddleware",
"django.middleware.common.CommonMiddleware",
]
CORS_ORIGIN_WHITELIST = [
'http://localhost:8000',
'http://127.0.0.1:8000/'
]
Then that should do it. If not, then here’s step 3):
- In your settings.py file:
INSTALLED_APPS = [
...,
"corsheader"
...,
]
From the django-cors-headers 3.14.0 package documentation:
This [django-cors-headers] allows in-browser requests to your Django application from other origins.
You can access the package and read more about it by following this link: https://pypi.org/project/django-cors-headers/
I hope this helped.
- [Vuejs]-Upload an image to a MongoDB database with Vue, TypeScript, Express and Multer
- [Vuejs]-How can I disable selecting a particular date in a VCalendar Date Picker?
Source:stackexchange.com