fix: require api key for serve

This commit is contained in:
hamb1y
2026-07-08 12:16:12 +08:00
committed by Xubin Ren
parent a7b8a9ed46
commit 6c59332a8a
2 changed files with 24 additions and 8 deletions
+6 -6
View File
@@ -1149,13 +1149,13 @@ def serve(
console.print(" [cyan]Session[/cyan] : api:default")
console.print(f" [cyan]Timeout[/cyan] : {timeout}s")
api_key = api_cfg.api_key.strip() if api_cfg.api_key else ""
if not api_key:
console.print(
"[red]Error: api_key is not set. "
"Set api.api_key in config to prevent unauthenticated API access.[/red]"
)
raise typer.Exit(1)
if host in {"0.0.0.0", "::"}:
if not api_key:
console.print(
"[red]Error: host is 0.0.0.0 (all interfaces) but api_key is not set. "
"Set api.api_key in config to prevent unauthenticated access.[/red]"
)
raise typer.Exit(1)
console.print(
"[yellow]API is bound to all interfaces "
"(authentication required).[/yellow]"