From 4e31e1384123b425fa06a8f234ea4da8befbb9b5 Mon Sep 17 00:00:00 2001 From: sameer0422 <168476827+sameer0422@users.noreply.github.com> Date: Mon, 23 Dec 2024 09:59:26 -0800 Subject: [PATCH] 25019 - Update GET/POST affiliation endpoints to support sandbox env (#3188) --- auth-api/src/auth_api/utils/util.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/auth-api/src/auth_api/utils/util.py b/auth-api/src/auth_api/utils/util.py index 55ab98f274..46b34c06c9 100644 --- a/auth-api/src/auth_api/utils/util.py +++ b/auth-api/src/auth_api/utils/util.py @@ -74,11 +74,15 @@ def mask_email(email: str) -> str: def get_request_environment(): """Return the environment corresponding to the user request.""" - env = None - sandbox_host = current_app.config["AUTH_WEB_SANDBOX_HOST"] - if os.getenv("FLASK_ENV") == "production" and sandbox_host in request.host_url: - env = "sandbox" - return env + env_override = request.headers.get("Environment-Override") + sandbox_host = current_app.config.get("AUTH_WEB_SANDBOX_HOST") + is_production = os.getenv("FLASK_ENV") == "production" + + if env_override: + return env_override + if is_production and sandbox_host in request.host_url: + return "sandbox" + return None def extract_numbers(input_string: str):