From cc7f9979344827374dbf034ded9e0c7fc64ab1db Mon Sep 17 00:00:00 2001 From: ajnisbet Date: Tue, 20 Feb 2024 11:46:21 -0800 Subject: [PATCH] Tidy cors --- opentopodata/api.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/opentopodata/api.py b/opentopodata/api.py index ea8d675..992a62d 100644 --- a/opentopodata/api.py +++ b/opentopodata/api.py @@ -85,10 +85,9 @@ def apply_cors(response): of the access_control_allow_origin config option. """ try: - if _load_config()["access_control_allow_origin"]: - response.headers["access-control-allow-origin"] = _load_config()[ - "access_control_allow_origin" - ] + cors_value = _load_config()["access_control_allow_origin"] + if cors_value: + response.headers["access-control-allow-origin"] = cors_value except config.ConfigError: # If the config isn't loading, allow the request to complete without # CORS so user can see error message.