Browse Source

fix(core): fallback to index.html on asset loading, closes #2020 #2021 (#2022)

Lucas Fernandes Nogueira 4 years ago
parent
commit
8a7921e5cb
2 changed files with 10 additions and 0 deletions
  1. 5 0
      .changes/fix-asset-loading-vue-router.md
  2. 5 0
      core/tauri/src/manager.rs

+ 5 - 0
.changes/fix-asset-loading-vue-router.md

@@ -0,0 +1,5 @@
+---
+"tauri": patch
+---
+
+Fallback to `index.html` on asset loading so router with history mode works.

+ 5 - 0
core/tauri/src/manager.rs

@@ -427,6 +427,11 @@ impl<P: Params> WindowManager<P> {
 
         let asset_response = assets
           .get(&path)
+          .or_else(|| {
+            #[cfg(debug_assertions)]
+            eprintln!("Asset `{}` not found; fallback to index.html", path); // TODO log::error!
+            assets.get("index.html")
+          })
           .ok_or(crate::Error::AssetNotFound(path))
           .map(Cow::into_owned);
         match asset_response {