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(