Cross Origin Access Issues - Django 2.1.7
I have gone through literally all SO links, reinstalled django and django-cors-headers and followed this to the T and yet we get pre flight error cross origin not allowed Django
Solution 1:
CorsMiddleware should be placed as high as possible, especially before any middleware that can generate responses such as Django’s CommonMiddleware or Whitenoise’s WhiteNoiseMiddleware. If it is not before, it will not be able to add the CORS headers to these responses.
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware', # <-- should be at the top'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'corsheaders.middleware.CorsPostCsrfMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
Post a Comment for "Cross Origin Access Issues - Django 2.1.7"