diff --git a/docker-compose.yml b/docker-compose.yml index 5503a04..1d8b2ef 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -95,4 +95,4 @@ services: - librechat-data:/app/data volumes: - librechat-data: \ No newline at end of file + librechat-data: diff --git a/src/components/app_shell.rs b/src/components/app_shell.rs index c129558..37e084b 100644 --- a/src/components/app_shell.rs +++ b/src/components/app_shell.rs @@ -65,6 +65,7 @@ pub fn AppShell() -> Element { email: info.email, name: info.name, avatar_url: info.avatar_url, + librechat_url: info.librechat_url, class: sidebar_cls, on_nav: move |_| mobile_menu_open.set(false), } diff --git a/src/components/sidebar.rs b/src/components/sidebar.rs index 2327f16..d8beba0 100644 --- a/src/components/sidebar.rs +++ b/src/components/sidebar.rs @@ -13,7 +13,7 @@ enum NavTarget { /// Internal Dioxus route (rendered as `Link { to: route }`). Internal(Route), /// External URL opened in a new tab (rendered as ``). - External(&'static str), + External(String), } /// Navigation entry for the sidebar. @@ -43,6 +43,7 @@ pub fn Sidebar( name: String, email: String, avatar_url: String, + #[props(default = "http://localhost:3080".to_string())] librechat_url: String, #[props(default = "sidebar".to_string())] class: String, #[props(default)] on_nav: EventHandler<()>, ) -> Element { @@ -66,7 +67,7 @@ pub fn Sidebar( key: "chat", label: t(locale_val, "nav.chat"), // Opens LibreChat in a new tab; SSO via shared Keycloak realm. - target: NavTarget::External("http://localhost:3080"), + target: NavTarget::External(librechat_url.clone()), icon: rsx! { Icon { icon: BsChatDots, width: 18, height: 18 } }, }, NavItem { @@ -124,7 +125,7 @@ pub fn Sidebar( } } NavTarget::External(url) => { - let url = *url; + let url = url.clone(); rsx! { a { href: url, diff --git a/src/infrastructure/auth_check.rs b/src/infrastructure/auth_check.rs index 00b6c6c..6bbb8d8 100644 --- a/src/infrastructure/auth_check.rs +++ b/src/infrastructure/auth_check.rs @@ -24,13 +24,18 @@ pub async fn check_auth() -> Result { .map_err(|e| ServerFnError::new(format!("session read failed: {e}")))?; match user_state { - Some(u) => Ok(AuthInfo { - authenticated: true, - sub: u.sub, - email: u.user.email, - name: u.user.name, - avatar_url: u.user.avatar_url, - }), + Some(u) => { + let librechat_url = + std::env::var("LIBRECHAT_URL").unwrap_or_else(|_| "http://localhost:3080".into()); + Ok(AuthInfo { + authenticated: true, + sub: u.sub, + email: u.user.email, + name: u.user.name, + avatar_url: u.user.avatar_url, + librechat_url, + }) + } None => Ok(AuthInfo::default()), } } diff --git a/src/models/user.rs b/src/models/user.rs index e1f1883..a3367bd 100644 --- a/src/models/user.rs +++ b/src/models/user.rs @@ -22,6 +22,8 @@ pub struct AuthInfo { pub name: String, /// Avatar URL (from Keycloak picture claim) pub avatar_url: String, + /// LibreChat instance URL for the sidebar chat link + pub librechat_url: String, } /// Per-user LLM provider configuration stored in MongoDB.