From ed3ceaf5ad4aedc76ba0c7f2f2fe353c0920a870 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Fri, 21 Nov 2025 22:11:46 +0530 Subject: [PATCH] feat: allow www domain for embedded websites (#60) --- api/routes/public_embed.py | 19 +++++++++++++++++-- api/services/pipecat/service_factory.py | 8 +++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/api/routes/public_embed.py b/api/routes/public_embed.py index bead318..5d6481c 100644 --- a/api/routes/public_embed.py +++ b/api/routes/public_embed.py @@ -71,6 +71,16 @@ def validate_origin(origin: str, allowed_domains: list) -> bool: else: domain = origin + # Normalize domain for www matching + def normalize_www(d: str) -> tuple[str, str]: + """Return both www and non-www versions of a domain""" + if d.startswith("www."): + return (d, d[4:]) # (www.x.com, x.com) + else: + return (d, f"www.{d}") # (x.com, www.x.com) + + domain_variants = normalize_www(domain) + for allowed in allowed_domains: if allowed == "*": return True @@ -79,8 +89,13 @@ def validate_origin(origin: str, allowed_domains: list) -> bool: base_domain = allowed[2:] if domain == base_domain or domain.endswith("." + base_domain): return True - elif domain == allowed: - return True + else: + # Check both www and non-www versions + allowed_variants = normalize_www(allowed) + # If any variant of domain matches any variant of allowed, it's valid + if any(dv in allowed_variants or av in domain_variants + for dv in domain_variants for av in allowed_variants): + return True return False diff --git a/api/services/pipecat/service_factory.py b/api/services/pipecat/service_factory.py index 5dfbe09..07b4cb1 100644 --- a/api/services/pipecat/service_factory.py +++ b/api/services/pipecat/service_factory.py @@ -6,7 +6,7 @@ from api.constants import MPS_API_URL from api.services.configuration.registry import ServiceProviders from pipecat.services.azure.llm import AzureLLMService from pipecat.services.cartesia.stt import CartesiaSTTService -from pipecat.services.deepgram.stt import DeepgramSTTService +from pipecat.services.deepgram.stt import DeepgramSTTService, LiveOptions from pipecat.services.deepgram.tts import DeepgramTTSService from pipecat.services.dograh.llm import DograhLLMService from pipecat.services.dograh.stt import DograhSTTService @@ -25,7 +25,13 @@ if TYPE_CHECKING: def create_stt_service(user_config): """Create and return appropriate STT service based on user configuration""" if user_config.stt.provider == ServiceProviders.DEEPGRAM.value: + live_options = LiveOptions( + language="multi", + profanity_filter=False, + endpointing=100 + ) return DeepgramSTTService( + live_options=live_options, api_key=user_config.stt.api_key, audio_passthrough=False, # Disable passthrough since audio is buffered separately )