Skip to content

Commit 0bff8c3

Browse files
fix(cli): Ignore query parameter in dev server (#8697)
* fix(cli): Ignore query parameter in dev server fixes #8148 additional ref: https://discord.com/channels/616186924390023171/1201199918379974766 * Update .changes/cli-devserver-queryparam.md --------- Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
1 parent a9b2c06 commit 0bff8c3

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-cli": patch:bug
3+
"@tauri-apps/cli": patch:bug
4+
---
5+
6+
Fix the built-in dev server failing to serve files when URL had queries `?` and other url components.

tooling/cli/src/helpers/web_dev_server.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,13 @@ pub fn start_dev_server<P: AsRef<Path>>(path: P, port: Option<u16>) -> crate::Re
123123
}
124124

125125
async fn handler(uri: axum::http::Uri, state: Arc<State>) -> impl IntoResponse {
126-
let uri = uri.to_string();
126+
// Frontend files should not contain query parameters. This seems to be how vite handles it.
127+
let uri = uri.path();
128+
127129
let uri = if uri == "/" {
128-
&uri
130+
uri
129131
} else {
130-
uri.strip_prefix('/').unwrap_or(&uri)
132+
uri.strip_prefix('/').unwrap_or(uri)
131133
};
132134

133135
let file = std::fs::read(state.serve_dir.join(uri))

0 commit comments

Comments
 (0)