allow base_path in the CLI

This commit is contained in:
Evan Almloff committed 2023-11-15 08:23:12 -06:00
1 parent 109e10e406
commit cd48b3b7f9
4 files changed
+28 -13

No files matched your search

+1 -1
View File
@@ -37,7 +37,7 @@ hyper-rustls = "0.23.2"
indicatif = "0.17.5"
subprocess = "0.2.9"
axum = { version = "0.5.1", features = ["ws", "headers"] }
axum = { version = "0.6.20", features = ["ws", "headers"] }
axum-server = { version = "0.5.1", features = ["tls-rustls"] }
tower-http = { version = "0.2.2", features = ["full"] }
headers = "0.3.7"
-3
View File
@@ -33,9 +33,6 @@ impl Serve {
crate_config.set_features(self.serve.features.unwrap());
}
// Subdirectories don't work with the server
crate_config.dioxus_config.web.app.base_path = None;
let platform = self
.serve
.platform
+15
View File
@@ -310,6 +310,21 @@ async fn setup_router(
},
));
router = if let Some(base_path) = config.dioxus_config.web.app.base_path.clone() {
let base_path = format!("/{}", base_path.trim_matches('/'));
Router::new()
.nest_service(
&base_path,
axum::routing::method_routing::any_service(router),
)
.fallback(get(move || {
let base_path = base_path.clone();
async move { format!("Outside of the base path: {}", base_path) }
}))
} else {
router
};
// Setup routes
router = router
.route("/_dioxus/hot_reload", get(hot_reload_handler))