Add static file serving for suite UI
- Serve suite UI from botui (dev) or botserver-stack (installed) - SPA fallback to index.html for client-side routing - Search paths: ../botui/ui/suite, ./botserver-stack/ui/suite, ./ui/suite
This commit is contained in:
parent
30d433e409
commit
dfd0dded23
2 changed files with 30 additions and 4 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"base_url": "http://localhost:8080",
|
"base_url": "http://localhost:8080",
|
||||||
"default_org": {
|
"default_org": {
|
||||||
"id": "350493764617240590",
|
"id": "350496350137221134",
|
||||||
"name": "default",
|
"name": "default",
|
||||||
"domain": "default.localhost"
|
"domain": "default.localhost"
|
||||||
},
|
},
|
||||||
|
|
@ -13,8 +13,8 @@
|
||||||
"first_name": "Admin",
|
"first_name": "Admin",
|
||||||
"last_name": "User"
|
"last_name": "User"
|
||||||
},
|
},
|
||||||
"admin_token": "PQV0tJlkYiGwiXCbaGDszHZZEJ5zNeCppXq4C8Ryi4A_astZuM_aYZUEq1PnNbn6g7Mcc_A",
|
"admin_token": "1Mjv1cz99jRBeVX0NQu952oxB7b-KRipXfbIHunkQJPk84VtAU2sv8IXRAULNATqDK50eHQ",
|
||||||
"project_id": "",
|
"project_id": "",
|
||||||
"client_id": "350493765221285902",
|
"client_id": "350496350741266446",
|
||||||
"client_secret": "KHKXlgoRPdVLhwjnjoy0DvCSREdGv5ukRA2ZhTeSyCjRZrSkZKEc6aQ2pG351nlM"
|
"client_secret": "kT6p8ekl4XtYGyW2esFeLlWHQMoxVUQzxcafiglFKA5X8DzTMtNhbOoUMkIGRtoi"
|
||||||
}
|
}
|
||||||
26
src/main.rs
26
src/main.rs
|
|
@ -278,6 +278,24 @@ async fn run_axum_server(
|
||||||
// Add OAuth authentication routes
|
// Add OAuth authentication routes
|
||||||
api_router = api_router.merge(crate::core::oauth::routes::configure());
|
api_router = api_router.merge(crate::core::oauth::routes::configure());
|
||||||
|
|
||||||
|
// Serve static files for suite UI
|
||||||
|
// Look for UI files in multiple locations (dev vs installed)
|
||||||
|
let ui_paths = vec![
|
||||||
|
"../botui/ui/suite", // Development: sibling project
|
||||||
|
"./botserver-stack/ui/suite", // Installed: in stack
|
||||||
|
"./ui/suite", // Local: in botserver dir
|
||||||
|
];
|
||||||
|
|
||||||
|
let ui_service = ui_paths
|
||||||
|
.iter()
|
||||||
|
.find(|p| std::path::Path::new(p).exists())
|
||||||
|
.map(|p| {
|
||||||
|
info!("Serving suite UI from: {}", p);
|
||||||
|
tower_http::services::ServeDir::new(p).not_found_service(
|
||||||
|
tower_http::services::ServeFile::new(format!("{}/index.html", p)),
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
// API routes
|
// API routes
|
||||||
.merge(api_router.with_state(app_state.clone()))
|
.merge(api_router.with_state(app_state.clone()))
|
||||||
|
|
@ -286,6 +304,14 @@ async fn run_axum_server(
|
||||||
.layer(cors)
|
.layer(cors)
|
||||||
.layer(TraceLayer::new_for_http());
|
.layer(TraceLayer::new_for_http());
|
||||||
|
|
||||||
|
// Add static file serving if UI directory exists
|
||||||
|
let app = if let Some(ui) = ui_service {
|
||||||
|
app.fallback_service(ui)
|
||||||
|
} else {
|
||||||
|
warn!("Suite UI not found in any of: {:?}", ui_paths);
|
||||||
|
app
|
||||||
|
};
|
||||||
|
|
||||||
// Always use HTTPS - load certificates from botserver-stack
|
// Always use HTTPS - load certificates from botserver-stack
|
||||||
let cert_dir = std::path::Path::new("./botserver-stack/conf/system/certificates");
|
let cert_dir = std::path::Path::new("./botserver-stack/conf/system/certificates");
|
||||||
let cert_path = cert_dir.join("api/server.crt");
|
let cert_path = cert_dir.join("api/server.crt");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue