From c772f776aa9ba0b3b20e58bbba9a56383882ee32 Mon Sep 17 00:00:00 2001 From: Terry van Walen Date: Fri, 12 Apr 2024 11:12:26 +0200 Subject: [PATCH] Set cors only when cors_domains is set --- src/main/settings.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/settings.py b/src/main/settings.py index 1e35eb8..0329534 100644 --- a/src/main/settings.py +++ b/src/main/settings.py @@ -29,12 +29,13 @@ ALLOWED_HOSTS = ["*"] -CORS_ALLOWED_ORIGINS = os.getenv("CORS_DOMAINS", '').split(',') -CORS_ALLOW_METHODS = ("GET",) -CORS_ALLOW_HEADERS = [ - *default_headers, - "X-Api-Key", -] +if CORS_DOMAINS := os.getenv("CORS_DOMAINS", ""): + CORS_ALLOWED_ORIGINS = CORS_DOMAINS.split(",") + CORS_ALLOW_METHODS = ("GET",) + CORS_ALLOW_HEADERS = [ + *default_headers, + "X-Api-Key", + ] INTERNAL_IPS = ("127.0.0.1", "0.0.0.0")