Added django-cors-headers setup steps to base settings

This commit is contained in:
Aadith PM 2020-07-18 19:53:55 -05:00
parent 1526aafab3
commit eafe74262a

View File

@ -80,6 +80,7 @@ THIRD_PARTY_APPS = [
{%- if cookiecutter.use_drf == "y" %}
"rest_framework",
"rest_framework.authtoken",
"corsheaders",
{%- endif %}
]
@ -134,6 +135,9 @@ AUTH_PASSWORD_VALIDATORS = [
# https://docs.djangoproject.com/en/dev/ref/settings/#middleware
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
{%- if cookiecutter.use_drf == 'y' %}
"corsheaders.middleware.CorsMiddleware",
{%- endif %}
{%- if cookiecutter.use_whitenoise == 'y' %}
"whitenoise.middleware.WhiteNoiseMiddleware",
{%- endif %}
@ -321,6 +325,12 @@ REST_FRAMEWORK = {
),
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
}
# django-cors-headers - https://github.com/adamchainz/django-cors-headers#setup
CORS_URLS_REGEX = {
r'^/api.*$',
}
{%- endif %}
# Your stuff...
# ------------------------------------------------------------------------------