DioxusLabs/dioxus · error

Proxy backend URL must have a non-empty path, e.g. {}/api in

Error message

Proxy backend URL must have a non-empty path, e.g. {}/api instead of {}

What it means

Configuration guard in add_proxy: the proxy backend URL parsed from Dioxus.toml's web proxy config has an empty path component, so there is no route prefix (like /api) to register proxy routes for. The inputs at fault are the configured backend URL and the suggested non-empty-path alternative shown in the message.

Source

Thrown at packages/cli/src/serve/proxy.rs:88

        .send_request(req)
        .await
        .map_err(|e| handle_error(anyhow::anyhow!("Request failed: {e}")))
}

/// Add routes to the router handling the specified proxy config.
///
/// We will proxy requests directed at either:
///
/// - the exact path of the proxy config's backend URL, e.g. /api
/// - the exact path with a trailing slash, e.g. /api/
/// - any subpath of the backend URL, e.g. /api/foo/bar
pub(crate) fn add_proxy(mut router: Router, proxy: &WebProxyConfig) -> Result<Router> {
    let url: Uri = proxy.backend.parse()?;
    let path = url.path().to_string();
    let trimmed_path = path.trim_start_matches('/');

    if trimmed_path.is_empty() {
        bail!(
            "Proxy backend URL must have a non-empty path, e.g. {}/api instead of {}",
            proxy.backend.trim_end_matches('/'),
            proxy.backend
        );
    }

    let method_router = proxy_to(url, false, handle_proxy_error);

    // api/*path
    router = router.route(
        &format!("/{}/{{*path}}", trimmed_path.trim_end_matches('/')),
        method_router.clone(),
    );

    // /api/
    router = router.route(
        &format!("/{}/", trimmed_path.trim_end_matches('/')),
        method_router.clone(),

View on GitHub (pinned to 24f6a829df)

Solutions

  1. Give the proxy backend URL a non-empty path, e.g. http://localhost:8080/api.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/cli/src/serve/proxy.rs:88 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23). Data as JSON: /api/errors/9993c476df927b43. Report an issue: GitHub.