|
108 | 108 | "django_extensions", |
109 | 109 | "rest_framework_gis", |
110 | 110 | "revproxy", |
| 111 | + "corsheaders", |
111 | 112 | ] |
112 | 113 | PROJECT_APPS = ["common", "metadata", "baseline"] |
113 | 114 | INSTALLED_APPS = EXTERNAL_APPS + PROJECT_APPS |
|
116 | 117 | "django.middleware.gzip.GZipMiddleware", |
117 | 118 | "django.middleware.security.SecurityMiddleware", |
118 | 119 | "whitenoise.middleware.WhiteNoiseMiddleware", |
| 120 | + "corsheaders.middleware.CorsMiddleware", |
119 | 121 | "django.contrib.sessions.middleware.SessionMiddleware", |
120 | 122 | "django.middleware.locale.LocaleMiddleware", |
121 | 123 | "common.middleware.language.LanguageMiddleware", |
|
153 | 155 | "SEARCH_PARAM": "search", |
154 | 156 | } |
155 | 157 |
|
| 158 | + |
| 159 | +########## CORS CONFIGURATION |
| 160 | +# See: https://github.com/ottoyiu/django-cors-headers |
| 161 | +CORS_ALLOWED_ORIGINS = env.list("CORS_ALLOWED_ORIGINS", default=[]) |
| 162 | +CORS_ALLOWED_ORIGIN_REGEXES = env.list("CORS_ALLOWED_ORIGIN_REGEXES", default=[]) |
| 163 | +# when CORS_ALLOW_CREDENTIALS is True, it is not allowed to use |
| 164 | +# the wildcard / CORS_ALLOW_ALL_ORIGINS |
| 165 | +CORS_ALLOW_ALL_ORIGINS = False if (CORS_ALLOWED_ORIGINS or CORS_ALLOWED_ORIGIN_REGEXES) else True |
| 166 | +CORS_ALLOW_CREDENTIALS = True if (CORS_ALLOWED_ORIGINS or CORS_ALLOWED_ORIGIN_REGEXES) else False |
| 167 | + |
| 168 | +CSRF_TRUSTED_ORIGINS = env.list("CSRF_TRUSTED_ORIGINS", default=[]) |
| 169 | +########## End CORS CONFIGURATION |
| 170 | + |
156 | 171 | ROOT_URLCONF = "hea.urls" |
157 | 172 |
|
158 | 173 | TEMPLATES = [ |
|
0 commit comments