From cb4ad27e89fcc37990dfac3385a9b7b5f4f878e4 Mon Sep 17 00:00:00 2001 From: GW_MC <72297530+GWMCwing@users.noreply.github.com> Date: Sun, 31 May 2026 02:36:42 +0000 Subject: [PATCH] refactor: enhance asset retrieval logic to support fallback for client subfolder --- apps/nxmesh-master/src/routes/frontend/mod.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/nxmesh-master/src/routes/frontend/mod.rs b/apps/nxmesh-master/src/routes/frontend/mod.rs index db345f6..4b49fe5 100644 --- a/apps/nxmesh-master/src/routes/frontend/mod.rs +++ b/apps/nxmesh-master/src/routes/frontend/mod.rs @@ -37,7 +37,11 @@ pub async fn get_fallback_handler() -> Result>, axu } fn get_index_html() -> Option> { - FrontendAssets::get(INDEX_HTML).map(|asset| asset.data.as_ref().to_owned()) + // Try root index.html first, then fall back to client/index.html when assets + // are packaged under the `client/` subfolder. + FrontendAssets::get(INDEX_HTML) + .or_else(|| FrontendAssets::get(&format!("client/{}", INDEX_HTML))) + .map(|asset| asset.data.as_ref().to_owned()) } async fn get_file_handler( @@ -49,7 +53,10 @@ async fn get_file_handler( path }; - match FrontendAssets::get(&file_path) { + // Try direct lookup first, then fallback to the `client/` subfolder. + match FrontendAssets::get(&file_path) + .or_else(|| FrontendAssets::get(&format!("client/{}", file_path))) + { Some(asset) => { let content_type = mime_guess::from_path(&file_path).first_or_octet_stream(); let response = axum::response::Response::builder()