xxxxxxxxxx
Install from pip:
python -m pip install django-cors-headers
and then add it to your installed apps:
INSTALLED_APPS = [
,
"corsheaders",
,
]
You will also need to add a middleware class to listen in on responses:
MIDDLEWARE = [
,
"corsheaders.middleware.CorsMiddleware",
"django.middleware.common.CommonMiddleware",
,
]
xxxxxxxxxx
$ pipenv install django-cors-headers
# or
$ pip install django-cors-headers
xxxxxxxxxx
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
]
xxxxxxxxxx
CORS_ALLOWED_ORIGINS = [
"https://example.com",
"https://sub.example.com",
"http://localhost:8080",
"http://127.0.0.1:9000"
]