feat: support configured production API endpoint

This commit is contained in:
2026-10-25 16:51:27 +03:00
parent 4203e5674c
commit 5b19094a4d
5 changed files with 89 additions and 16 deletions
+17 -8
View File
@@ -41,9 +41,17 @@ def _cached_detect(token):
if cache is None:
g._detected_endpoint = cache = {}
if token not in cache:
endpoint = current_app.config["NUBES_API_ENDPOINT"]
if endpoint in STANDS:
endpoint = detect_endpoint(token) or endpoint
endpoint = current_app.config["NUBES_API_ENDPOINT"].rstrip("/")
endpoints = [url.rstrip("/") for url in STANDS]
for configured_endpoint in (
current_app.config.get("NUBES_API_PROD_ENDPOINT", ""),
endpoint,
):
configured_endpoint = configured_endpoint.rstrip("/")
if configured_endpoint and configured_endpoint not in endpoints:
endpoints.append(configured_endpoint)
if endpoint in endpoints:
endpoint = detect_endpoint(token, endpoints=endpoints) or endpoint
cache[token] = endpoint
return cache[token]
@@ -137,11 +145,12 @@ def get_stand():
return f"polygon_{get_polygon_stand()}"
token = get_token()
endpoint = current_app.config["NUBES_API_ENDPOINT"]
if endpoint not in STANDS:
s = stand_name(endpoint)
return s if s != "?" else "mock"
return stand_name(_cached_detect(token))
endpoint = _cached_detect(token).rstrip("/")
prod_endpoint = current_app.config.get("NUBES_API_PROD_ENDPOINT", "").rstrip("/")
if prod_endpoint and endpoint == prod_endpoint:
return "prod"
s = stand_name(endpoint)
return s if s != "?" else "mock"
def get_token_info():