Skip to content

Commit

Permalink
Support push-state based routing
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Aug 11, 2024
1 parent 8cc0795 commit 83884a8
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion crates/tauri-plugin-holochain/src/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,22 @@ pub async fn read_asset(

match std::fs::read(asset_file.clone()) {
Ok(asset) => Ok(Some((asset, mime_type))),
Err(_e) => Ok(None),
Err(_e) => {
// Fallback to "index.html" to support push-based client-side routing without hashing
let asset_file = assets_path.join(String::from("index.html"));
let mime_guess = mime_guess::from_path(asset_file.clone());

let mime_type = match mime_guess.first() {
Some(mime) => Some(mime.essence_str().to_string()),
None => {
log::warn!("Could not determine MIME Type of file '{:?}'", asset_file);
None
}
};
match std::fs::read(asset_file.clone()) {
Ok(asset) => Ok(Some((asset, mime_type))),
Err(_e) => Ok(None)
}
},
}
}

0 comments on commit 83884a8

Please sign in to comment.