Added django-cors-headers setup steps to base settings
@@ -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...
# ------------------------------------------------------------------------------
