Panic in `ClientRequest::new` when using `base_path`
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
unwrappanics onurl::ParseError::RelativeUrlWithoutBase. - This happens because it tries to parse
"/{base_path}/api/{function}"tourl::Url(where{base_path}is the one defined inDioxus.toml). - Which in turn happens because
get_server_urlreturned"/{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
I'm also seeing this issue, my site isn't working after upgrading from 0.6.0 -> 0.7.1
@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.
base_path = "foo". No slashes or anything.
Same for me, a single [a-z]+ path segment.
Same for me, a single
[a-z]+path segment.
base_path = "foo". No slashes or anything.
Thank you both!
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();`