Fix the base path in the CLI (#2756)

This commit is contained in:
Evan Almloff authored and GitHub committed 2024-07-31 15:54:39 -07:00
1 parent 4bf71111c8
commit b8565e6de0
4 files changed
+37 -31

No files matched your search

+1 -1
View File
@@ -65,7 +65,7 @@ impl Builder {
if let Err(err) = &res {
let _ = tx.start_send(UpdateBuildProgress {
stage: crate::builder::Stage::Finished,
update: crate::builder::UpdateStage::Failed(err.to_string()),
update: crate::builder::UpdateStage::Failed(format!("{err}")),
});
}
+13 -11
View File
@@ -360,21 +360,23 @@ fn setup_router(
router = super::proxy::add_proxy(router, proxy_config)?;
}
// Setup base path redirection
if let Some(base_path) = config.dioxus_config.web.app.base_path.clone() {
let base_path = format!("/{}", base_path.trim_matches('/'));
router = Router::new()
.nest(&base_path, router)
.fallback(get(move || async move {
format!("Outside of the base path: {}", base_path)
}));
}
// server the dir if it's web, otherwise let the fullstack server itself handle it
match platform {
Platform::Web => {
// Route file service to output the .wasm and assets if this is a web build
router = router.nest_service("/", build_serve_dir(serve, config));
let base_path = format!(
"/{}",
config
.dioxus_config
.web
.app
.base_path
.as_deref()
.unwrap_or_default()
.trim_matches('/')
);
router = router.nest_service(&base_path, build_serve_dir(serve, config));
}
Platform::Fullstack | Platform::StaticGeneration => {
// For fullstack and static generation, forward all requests to the server