diff --git a/.changes/cli-devserver-queryparam.md b/.changes/cli-devserver-queryparam.md new file mode 100644 index 000000000000..d92284b2272e --- /dev/null +++ b/.changes/cli-devserver-queryparam.md @@ -0,0 +1,6 @@ +--- +"tauri-cli": patch:bug +"@tauri-apps/cli": patch:bug +--- + +Fix the built-in dev server failing to serve files when URL had queries `?` and other url components. diff --git a/tooling/cli/src/helpers/web_dev_server.rs b/tooling/cli/src/helpers/web_dev_server.rs index ff05ab556416..cda460484ce7 100644 --- a/tooling/cli/src/helpers/web_dev_server.rs +++ b/tooling/cli/src/helpers/web_dev_server.rs @@ -123,11 +123,13 @@ pub fn start_dev_server>(path: P, port: Option) -> crate::Re } async fn handler(uri: axum::http::Uri, state: Arc) -> impl IntoResponse { - let uri = uri.to_string(); + // Frontend files should not contain query parameters. This seems to be how vite handles it. + let uri = uri.path(); + let uri = if uri == "/" { - &uri + uri } else { - uri.strip_prefix('/').unwrap_or(&uri) + uri.strip_prefix('/').unwrap_or(uri) }; let file = std::fs::read(state.serve_dir.join(uri))