Answers for "enable cors in django"

0

django how to avoid cors issue

pip install django-cors-headers
#settings.py
INSTALLED_APPS = [
    ...
    'corsheaders',
    ...
]
MIDDLEWARE = [
    ...
    'corsheaders.middleware.CorsMiddleware',
    ...
]
ALLOWED_HOSTS=['*']
CORS_ORIGIN_ALLOW_ALL = True
Posted by: Guest on October-07-2021
-1

install crossheaders in django

pip install django-cors-headers

#Add corsheaders to installed applications in settings.py:

INSTALLED_APPS = [
    ...
    'corsheaders',
]

#Add corsheaders.middleware.CorsMiddleware to middleware section in settings.py:

MIDDLEWARE = [
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    ...

]

#Allow access to all domains by setting the following variable to TRUE in settings.py:
DEBUG = True

ALLOWED_HOSTS = []

CORS_ORIGIN_ALLOW_ALL = True
Posted by: Guest on September-29-2020
0

django cors install

pip install django-cors-headers
Posted by: Guest on August-01-2021

Python Answers by Framework

Browse Popular Code Answers by Language