Merge pull request #28588 from edx/loading-cors-origins-with-shceme
feat: `djang-cor-headers` need schemes with urls. Condition added for future.
This commit is contained in:
@@ -16,8 +16,10 @@ from corsheaders.defaults import default_headers as corsheaders_default_headers
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.urls import reverse_lazy
|
||||
from edx_django_utils.plugins import add_plugins
|
||||
from importlib.metadata import version
|
||||
from path import Path as path
|
||||
|
||||
|
||||
from openedx.core.djangoapps.plugins.constants import ProjectType, SettingsType
|
||||
|
||||
from .common import *
|
||||
@@ -554,6 +556,13 @@ derive_settings(__name__)
|
||||
if FEATURES.get('ENABLE_CORS_HEADERS'):
|
||||
CORS_ALLOW_CREDENTIALS = True
|
||||
CORS_ORIGIN_WHITELIST = ENV_TOKENS.get('CORS_ORIGIN_WHITELIST', ())
|
||||
|
||||
# values are already updated above with default CORS_ORIGIN_WHITELIST values but in
|
||||
# case of new version django_cors_headers they will get override.
|
||||
cors_major_version = int(version('django_cors_headers').split('.')[0])
|
||||
if cors_major_version >= 3 and CORS_ORIGIN_WHITELIST and ENV_TOKENS.get('CORS_ORIGIN_WHITELIST_WITH_SCHEME'):
|
||||
CORS_ORIGIN_WHITELIST = ENV_TOKENS.get('CORS_ORIGIN_WHITELIST_WITH_SCHEME')
|
||||
|
||||
CORS_ORIGIN_ALLOW_ALL = ENV_TOKENS.get('CORS_ORIGIN_ALLOW_ALL', False)
|
||||
CORS_ALLOW_INSECURE = ENV_TOKENS.get('CORS_ALLOW_INSECURE', False)
|
||||
CORS_ALLOW_HEADERS = corsheaders_default_headers + (
|
||||
|
||||
Reference in New Issue
Block a user