DioxusLabs / DioxusLabs/dioxus

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

Open
#5,032 7 comments 5 reactions 0 assignees View on GitHub
bug fullstack
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

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`](https://github.com/DioxusLabs/dioxus/blob/v0.7.1/packages/fullstack/src/client.rs#L51) 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](https://github.com/DioxusLabs/dioxus/blob/v0.7.1/packages/dioxus/src/launch.rs#L326), `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](https://github.com/DioxusLabs/dioxus/blob/v0.7.1/packages/fullstack/src/client.rs#L156) later.)_~~

**Environment:**

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with packages/fullstack/src/client.rs at the unwrap around line 51 and the relative URL generation around line 156, then inspect packages/dioxus/src/launch.rs around line 326. Reproduce the first server-function call with a Dioxus.toml base_path and trace the server URL and generated relative URL. Done means the call no longer panics and the base path is preserved in the resulting request URL.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.