BigPizzaV3/CodexPlusPlus · error

Base URL 缺少主机名

Error message

Base URL 缺少主机名

What it means

In validate_llm_proxy_url, after the URL parses and passes scheme/credential checks, url.host_str() must yield a host. This error fires when the URL has no host component (e.g. scheme-only or file-style URL), so the proxy endpoint would be unroutable.

Source

Thrown at crates/codex-plus-core/src/routes.rs:778

        "status": "ok",
        "http_status": http_status,
        "ok": ok,
        "body_text": body_text,
        "body_json": body_json,
    }))
}

fn validate_llm_proxy_url(raw: &str) -> anyhow::Result<reqwest::Url> {
    let url = reqwest::Url::parse(raw.trim()).map_err(|_| anyhow::anyhow!("Base URL 格式无效"))?;
    if url.scheme() != "https" {
        anyhow::bail!("Base URL 必须使用 HTTPS");
    }
    if !url.username().is_empty() || url.password().is_some() {
        anyhow::bail!("Base URL 不得包含用户名或密码");
    }
    let host = url
        .host_str()
        .ok_or_else(|| anyhow::anyhow!("Base URL 缺少主机名"))?;
    if is_blocked_llm_proxy_host(host) {
        anyhow::bail!("Base URL 不得指向本机或私有网络");
    }
    Ok(url)
}

fn is_blocked_llm_proxy_host(host: &str) -> bool {
    let host = host
        .trim()
        .trim_start_matches('[')
        .trim_end_matches(']')
        .to_lowercase();
    if host.is_empty()
        || host == "localhost"
        || host.ends_with(".localhost")
        || host.ends_with(".local")
    {
        return true;

View on GitHub (pinned to f2074595a2)

Solutions

  1. Add the hostname to the Base URL, e.g. https://api.example.com
  2. Do not use URLs without an authority component
  3. Re-check the provider documentation for the correct endpoint format
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/codex-plus-core/src/routes.rs:778 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@f2074595a2 (2026-08-23). Data as JSON: /api/errors/8da1ed3170afc981. Report an issue: GitHub.