Runner: strip protocol from proxy address

This commit is contained in:
Mark Backman
2025-08-01 19:48:27 -04:00
parent 1b3c2bee30
commit 3a8d809837
2 changed files with 28 additions and 0 deletions

View File

@@ -357,6 +357,27 @@ async def _run_daily_direct():
await bot_module.bot(runner_args)
def _validate_and_clean_proxy(proxy: str) -> str:
"""Validate and clean proxy hostname, removing protocol if present."""
if not proxy:
return proxy
original_proxy = proxy
# Strip common protocols
if proxy.startswith(("http://", "https://")):
proxy = proxy.split("://", 1)[1]
logger.warning(
f"Removed protocol from proxy URL. Using '{proxy}' instead of '{original_proxy}'. "
f"The --proxy argument expects only the hostname (e.g., 'mybot.ngrok.io')."
)
# Remove trailing slashes
proxy = proxy.rstrip("/")
return proxy
def main():
"""Start the Pipecat development runner.
@@ -408,6 +429,10 @@ def main():
args = parser.parse_args()
# Validate and clean proxy hostname
if args.proxy:
args.proxy = _validate_and_clean_proxy(args.proxy)
# Auto-set transport to daily if --direct is used without explicit transport
if args.direct and args.transport == "webrtc": # webrtc is the default
args.transport = "daily"