From bc5e227d81d4a9eb9f29bfbb6c444ef264f9aec7 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Sun, 29 Mar 2026 17:44:02 +0200 Subject: [PATCH] fix(tenancy): use correct base URL for invitation link in dev vs prod Dev (debug=True): http://localhost:8000/store/{store_code}/invitation/... Prod: https://{subdomain}.{main_domain}/invitation/... Previously used main_domain directly which pointed to the prod domain even in dev environments. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../tenancy/services/store_team_service.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/modules/tenancy/services/store_team_service.py b/app/modules/tenancy/services/store_team_service.py index 3f0cbc4b..262b60b1 100644 --- a/app/modules/tenancy/services/store_team_service.py +++ b/app/modules/tenancy/services/store_team_service.py @@ -983,10 +983,18 @@ class StoreTeamService: from app.core.config import settings as app_settings from app.modules.messaging.services.email_service import EmailService - domain = app_settings.main_domain.rstrip("/") - scheme = "http" if "localhost" in domain else "https" - base_url = f"{scheme}://{domain}" if "://" not in domain else domain - acceptance_link = f"{base_url}/store/invitation/accept?token={token}" + # Build acceptance URL using store's subdomain or main domain + store_subdomain = store.subdomain + main_domain = app_settings.main_domain.rstrip("/") + + if app_settings.debug or "localhost" in main_domain: + # Dev: use localhost with store path + base_url = f"http://localhost:8000/store/{store.store_code}" + else: + # Prod: use store subdomain + base_url = f"https://{store_subdomain}.{main_domain}" + + acceptance_link = f"{base_url}/invitation/accept?token={token}" email_service = EmailService(db) email_service.send_template(