configure cors and allowed hosts using env vars (#4355)

This commit is contained in:
Philipp Fruck 2023-02-16 23:53:28 +00:00 committed by GitHub
parent 6627a8097b
commit e6c9db2ff3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -102,6 +102,7 @@ MEDIA_ROOT = config.get_media_dir()
# List of allowed hosts (default = allow all) # List of allowed hosts (default = allow all)
ALLOWED_HOSTS = get_setting( ALLOWED_HOSTS = get_setting(
"INVENTREE_ALLOWED_HOSTS",
config_key='allowed_hosts', config_key='allowed_hosts',
default_value=['*'], default_value=['*'],
typecast=list, typecast=list,
@ -114,11 +115,13 @@ CORS_URLS_REGEX = r'^/api/.*$'
# Extract CORS options from configuration file # Extract CORS options from configuration file
CORS_ORIGIN_ALLOW_ALL = get_boolean_setting( CORS_ORIGIN_ALLOW_ALL = get_boolean_setting(
"INVENTREE_CORS_ORIGIN_ALLOW_ALL",
config_key='cors.allow_all', config_key='cors.allow_all',
default_value=False, default_value=False,
) )
CORS_ORIGIN_WHITELIST = get_setting( CORS_ORIGIN_WHITELIST = get_setting(
"INVENTREE_CORS_ORIGIN_WHITELIST",
config_key='cors.whitelist', config_key='cors.whitelist',
default_value=[], default_value=[],
typecast=list, typecast=list,