From b1a2f7171216b7cc170b8b11d1c907d6b2c3a5f1 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Wed, 10 Dec 2025 21:41:11 -0300 Subject: [PATCH] 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 --- config/directory_config.json | 8 ++++---- src/main.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/config/directory_config.json b/config/directory_config.json index ac20c1e57..dd2f83ed6 100644 --- a/config/directory_config.json +++ b/config/directory_config.json @@ -1,7 +1,7 @@ { "base_url": "http://localhost:8080", "default_org": { - "id": "350493764617240590", + "id": "350496350137221134", "name": "default", "domain": "default.localhost" }, @@ -13,8 +13,8 @@ "first_name": "Admin", "last_name": "User" }, - "admin_token": "PQV0tJlkYiGwiXCbaGDszHZZEJ5zNeCppXq4C8Ryi4A_astZuM_aYZUEq1PnNbn6g7Mcc_A", + "admin_token": "1Mjv1cz99jRBeVX0NQu952oxB7b-KRipXfbIHunkQJPk84VtAU2sv8IXRAULNATqDK50eHQ", "project_id": "", - "client_id": "350493765221285902", - "client_secret": "KHKXlgoRPdVLhwjnjoy0DvCSREdGv5ukRA2ZhTeSyCjRZrSkZKEc6aQ2pG351nlM" + "client_id": "350496350741266446", + "client_secret": "kT6p8ekl4XtYGyW2esFeLlWHQMoxVUQzxcafiglFKA5X8DzTMtNhbOoUMkIGRtoi" } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index f42e67ec5..916252d0d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -278,6 +278,24 @@ async fn run_axum_server( // Add OAuth authentication routes 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() // API routes .merge(api_router.with_state(app_state.clone())) @@ -286,6 +304,14 @@ async fn run_axum_server( .layer(cors) .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 let cert_dir = std::path::Path::new("./botserver-stack/conf/system/certificates"); let cert_path = cert_dir.join("api/server.crt");