diff --git a/app/main.py b/app/main.py index 0ea03a0..ef8e79e 100644 --- a/app/main.py +++ b/app/main.py @@ -13,22 +13,38 @@ from app.personas import ensure_dirs def get_subdomain_target(host: str) -> Optional[Tuple[str, str]]: """ - Inspects Host header and returns (target_backend_url, universe_id) if it matches a subdomain. - Examples: - tt.hub.yesminedor.tn -> (HERMES_TT_URL, 'tt') - nyora.hub.yesminedor.tn -> (HERMES_NYORA_URL, 'nyora') - perso.hub.yesminedor.tn -> (HERMES_PERSO_URL, 'perso') - nabil.hub.yesminedor.tn -> (HERMES_NABIL_URL, 'nabil') - dsh.hub.yesminedor.tn -> (DSH_FILEBROWSER_URL, 'nabil') + Inspects Host header and returns (target_backend_url, universe_id) if it matches a universe hostname. + + Hostnames (Dash-based 1st level): + tt-hub.yesminedor.tn -> (HERMES_TT_URL, 'tt') + nyora-hub.yesminedor.tn -> (HERMES_NYORA_URL, 'nyora') + perso-hub.yesminedor.tn -> (HERMES_PERSO_URL, 'perso') + nabil-hub.yesminedor.tn -> (HERMES_NABIL_URL, 'nabil') + dsh-hub.yesminedor.tn -> (DSH_FILEBROWSER_URL, 'nabil') + + Apex / Hub UI: + hub.yesminedor.tn -> None (Serves index.html Workspace Switcher) """ if not host: return None hostname = host.split(":")[0].lower() + # The main hub switcher UI should NOT be proxied + if hostname in ("hub.yesminedor.tn", "localhost", "127.0.0.1"): + return None + sub = None - if hostname.endswith(".hub.yesminedor.tn"): + # 1. New 1st level dash-based production hostnames (*-hub.yesminedor.tn) + if hostname.endswith("-hub.yesminedor.tn"): + sub = hostname.rsplit("-hub.yesminedor.tn", 1)[0] + # 2. Backward compatibility (*.hub.yesminedor.tn) + elif hostname.endswith(".hub.yesminedor.tn"): sub = hostname.rsplit(".hub.yesminedor.tn", 1)[0] + # 3. Localhost dash development (*-hub.localhost) + elif hostname.endswith("-hub.localhost"): + sub = hostname.rsplit("-hub.localhost", 1)[0] + # 4. Localhost dot development (*.localhost) elif hostname.endswith(".localhost"): sub = hostname.rsplit(".localhost", 1)[0] diff --git a/app/templates/index.html b/app/templates/index.html index 1943d23..41a51ee 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -3,11 +3,18 @@ {% block content %}