dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

Panic in `ClientRequest::new` when using `base_path`

Open Ltrlg opened this issue 1 month ago • 6 comments

In one of my currently-migrating-projects, the first server function call panics. Here is what I managed to debug:

  • The visible effect is that this unwrap panics on url::ParseError::RelativeUrlWithoutBase.
  • This happens because it tries to parse "/{base_path}/api/{function}" to url::Url (where {base_path} is the one defined in Dioxus.toml).
  • Which in turn happens because get_server_url returned "/{base_path}" (which, not being empty, was not replaced with "http://this.is.not.a.real.url:9000")
  • … because at the previous set point, get_server_url() returned an empty string, which got concatenated to the base path.

(Looks like fixing this problem is not enough for my setup to work: The base path is missing when generating the actual relative URL later.)

Environment:

  • Dioxus version: 0.7.1
  • Rust version: 1.91.1
  • OS info: NixOS 25.05
  • App platform: web

Ltrlg avatar Nov 25 '25 23:11 Ltrlg

I'm also seeing this issue, my site isn't working after upgrading from 0.6.0 -> 0.7.1

Colecf avatar Nov 30 '25 23:11 Colecf

@Ltrlg and @Colecf What are your base_paths set to if anything? My PR #5049 was just merged and had similar issues if the base_path was set to /.

Let me know I can probably help with reproduction steps if the value is something else.

binarypie avatar Dec 04 '25 20:12 binarypie

base_path = "foo". No slashes or anything.

Colecf avatar Dec 05 '25 03:12 Colecf

Same for me, a single [a-z]+ path segment.

Ltrlg avatar Dec 05 '25 09:12 Ltrlg

Same for me, a single [a-z]+ path segment.

base_path = "foo". No slashes or anything.

Thank you both!

binarypie avatar Dec 05 '25 16:12 binarypie

use this fix in the file dioxus-fullstack-0.7.2/src/client.rs at( line 40) change them as below, then it works `

     let mut server_url = get_server_url().to_string();

    if server_url.is_empty() {
        server_url = "http://this.is.not.a.real.url:9000".to_string();
    }
    else {
        if server_url.starts_with("/") {
            server_url = format!("http://this.is.not.a.real.url:9000{}",server_url);
        }
    }

    let url = format!(
        "{server_url}{path}{params}",
        params = if query.is_empty() {
            "".to_string()
        } else {
            format!("?{}", query)
        }
    )
    .parse()
    .unwrap();`

min7318 avatar Dec 10 '25 07:12 min7318