Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

release: v2.3.6 — configurable ComfyUI host + OpenAI-compat local CORS fix

PurpleDoubleD65d2587d8a1d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 575c7001..c41c76ab 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,21 @@
All notable changes to Locally Uncensored are documented here.
+## [2.3.6] - 2026-04-21
+
+### Added
+- **Configurable ComfyUI host (remote ComfyUI support)** — Settings → ComfyUI → Host. Previously only the port was configurable; the host was hardcoded `localhost`, which meant users running ComfyUI in Docker, on a LAN machine, or on a headless homelab server couldn't point LU at it. The Host field accepts any hostname or IP. When the host resolves to the local machine (`localhost`, `127.0.0.1`, `::1`, `0.0.0.0`) the Start/Stop/Restart/Install/Path controls stay visible; when it's remote LU hides those controls and shows an amber hint that you manage the Python process on the server yourself. Requested in GitHub Discussion #1 by @ShoaibSajid (desktop LU + Ollama on server-1 + ComfyUI on server-1 docker). The mobile Remote proxy also honors the new host so mobile-dispatched ComfyUI calls reach the configured backend. 17 regression tests in `backend-urls.test.ts`.
+
+### Fixed
+- **ComfyUI port now actually persists across restarts** — pre-existing bug: `set_comfyui_port` wrote `comfyui_port` to `%APPDATA%/locally-uncensored/config.json`, but `AppState::new()` never read it back on startup. Users who set a custom port (e.g. because 8188 was taken) got their change reverted to 8188 on the next launch. New `load_comfy_config_values()` helper runs at startup and applies persisted port + host. Bundled with the host feature since they share the same config-load path.
+- **OpenAI-compat local backends (LM Studio, vLLM, llama.cpp server, KoboldCpp, oobabooga, Jan, GPT4All, Aphrodite, SGLang, TGI, LocalAI, TabbyAPI) can actually be reached from LU's Tauri webview** — `openai-provider.ts` used plain `fetch()` for `/v1/models`, `/v1/chat/completions`, and `checkConnection`, which CORS-blocks localhost requests inside the Tauri WebView (only Ollama had CORS open). The "Test" button in Settings → Providers always showed **Failed** and models never appeared in the dropdown even when the backend was obviously reachable via curl. Fix: each HTTP call now picks `localFetch`/`localFetchStream` when the provider baseUrl hostname is local (`localhost`/`127.0.0.1`/`::1`/`0.0.0.0`), which routes through the Rust proxy with a direct-fetch fallback. Cloud endpoints (OpenAI proper, OpenRouter, Groq, Together, DeepSeek, Mistral, etc.) skip the proxy since they don't have the localhost CORS issue. Surfaced during v2.3.6 live E2E against a real LM Studio server on :1234; the Djoks auto-detection fix (v2.3.5) was detecting + pre-enabling the provider correctly, but the actual /v1/* calls were silently CORS-rejected.
+
+### Changed
+- Test suite 2166 → 2183 green (+17 regression tests for `setComfyHost` / `isComfyLocal` / `comfyuiUrl` / `comfyuiWsUrl` with custom hosts).
+
+### Notes
+- Drop-in upgrade from v2.3.5. No breaking changes. The default host is still `localhost` — existing users see zero behavior change unless they explicitly switch to a remote host.
+
## [2.3.5] - 2026-04-21
### Fixed
diff --git a/package.json b/package.json
index b2c22edf..abcc0403 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "locally-uncensored",
- "version": "2.3.5",
+ "version": "2.3.6",
"private": false,
"description": "Generate anything — text, images, video. Locally. Uncensored.",
"license": "AGPL-3.0",
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index 32bdad03..653e8579 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -2508,7 +2508,7 @@ dependencies = [
[[package]]
name = "locally-uncensored"
-version = "2.3.5"
+version = "2.3.6"
dependencies = [
"axum",
"base64 0.22.1",
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index d3c8d371..1e83bf14 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "locally-uncensored"
-version = "2.3.5"
+version = "2.3.6"
description = "Private, local AI chat & image/video generation"
authors = ["purpledoubled"]
edition = "2021"
diff --git a/src-tauri/src/commands/process.rs b/src-tauri/src/commands/process.rs
index 1e4df2ca..e30359e6 100644
--- a/src-tauri/src/commands/process.rs
+++ b/src-tauri/src/commands/process.rs
@@ -235,6 +235,19 @@ pub fn start_ollama(_state: State<'_, AppState>) -> Result<serde_json::Value, St
#[tauri::command]
pub fn start_comfyui(state: State<'_, AppState>) -> Result<serde_json::Value, String> {
+ // If user pointed LU at a remote ComfyUI, we have no local process to spawn.
+ // Just report status — the remote side is responsible for running ComfyUI.
+ {
+ let host = state.comfy_host.lock().unwrap().clone();
+ if !is_local_host(&host) {
+ return Ok(serde_json::json!({
+ "status": "remote",
+ "host": host,
+ "message": "Remote ComfyUI — manage the Python process on the server itself"
+ }));
+ }
+ }
+
let port = *state.comfy_port.lock().unwrap();
if is_comfyui_running_on_port(port) {
@@ -339,11 +352,22 @@ pub fn stop_comfyui(state: State<'_, AppState>) -> Result<serde_json::Value, Str
#[tauri::command]
pub async fn comfyui_status(state: State<'_, AppState>) -> Result<serde_json::Value, String> {
let port = *state.comfy_port.lock().unwrap();
-
- let running = reqwest::get(format!("http://localhost:{}/system_stats", port))
- .await
- .map(|r| r.status().is_success())
- .unwrap_or(false);
+ let host = state.comfy_host.lock().unwrap().clone();
+ let is_local = is_local_host(&host);
+
+ // Probe the configured host (not just localhost). Remote ComfyUI
+ // still reports running: true if the /system_stats endpoint responds.
+ let running = reqwest::Client::builder()
+ .timeout(std::time::Duration::from_secs(3))
+ .build()
+ .ok()
+ .and_then(|c| Some(c.get(format!("http://{}:{}/system_stats", host, port))))
+ .map(|req| async move { req.send().await.map(|r| r.status().is_success()).unwrap_or(false) })
+ ;
+ let running = match running {
+ Some(fut) => fut.await,
+ None => false,
+ };
let process_alive = {
let proc = state.comfy_process.lock().unwrap();
@@ -355,7 +379,12 @@ pub async fn comfyui_status(state: State<'_, AppState>) -> Result<serde_json::Va
p.clone()
};
- let found = path.is_some() || find_comfyui_path().is_some();
+ // For remote hosts we don't care whether a local install path exists.
+ let found = if is_local {
+ path.is_some() || find_comfyui_path().is_some()
+ } else {
+ true // the remote side handles its own install
+ };
Ok(serde_json::json!({
"running": running,
@@ -363,10 +392,19 @@ pub async fn comfyui_status(state: State<'_, AppState>) -> Result<serde_json::Va
"found": found,
"path": path,
"port": port,
+ "host": host,
+ "isLocal": is_local,
"processAlive": process_alive,
}))
}
+/// Returns true when `host` refers to the local machine.
+/// Anything else = remote and LU won't try to manage the process.
+pub fn is_local_host(host: &str) -> bool {
+ let h = host.trim().to_ascii_lowercase();
+ matches!(h.as_str(), "localhost" | "127.0.0.1" | "::1" | "0.0.0.0" | "")
+}
+
#[tauri::command]
pub fn find_comfyui() -> Result<serde_json::Value, String> {
match find_comfyui_path() {
@@ -410,6 +448,47 @@ pub fn set_comfyui_path(path: String, state: State<'_, AppState>) -> Result<serd
Ok(serde_json::json!({"status": "saved", "path": path}))
}
+#[tauri::command]
+pub fn set_comfyui_host(host: String, state: State<'_, AppState>) -> Result<serde_json::Value, String> {
+ let trimmed = host.trim();
+ if trimmed.is_empty() {
+ return Err("Host must not be empty".to_string());
+ }
+ // Reject obviously invalid chars — helps avoid URL-injection style typos.
+ if trimmed.contains('/') || trimmed.contains(' ') || trimmed.contains('?') {
+ return Err("Host must be a plain hostname or IP, no slashes/spaces".to_string());
+ }
+ let final_host = trimmed.to_string();
+
+ {
+ let mut h = state.comfy_host.lock().unwrap();
+ *h = final_host.clone();
+ }
+
+ // Persist to config file
+ if let Some(config_dir) = dirs::config_dir() {
+ let app_config = config_dir.join("locally-uncensored");
+ let _ = fs::create_dir_all(&app_config);
+ let config_file = app_config.join("config.json");
+
+ let mut config: serde_json::Value = if config_file.exists() {
+ fs::read_to_string(&config_file)
+ .ok()
+ .and_then(|s| serde_json::from_str(&s).ok())
+ .unwrap_or_else(|| serde_json::json!({}))
+ } else {
+ serde_json::json!({})
+ };
+
+ config["comfyui_host"] = serde_json::json!(final_host);
+ let _ = fs::write(&config_file, serde_json::to_string_pretty(&config).unwrap());
+ }
+
+ let is_local = is_local_host(&final_host);
+ println!("[ComfyUI] Host set to {} (local={})", final_host, is_local);
+ Ok(serde_json::json!({"status": "saved", "host": final_host, "isLocal": is_local}))
+}
+
#[tauri::command]
pub fn set_comfyui_port(port: u16, state: State<'_, AppState>) -> Result<serde_json::Value, String> {
if port == 0 {
@@ -477,6 +556,15 @@ pub fn auto_start_ollama(_state: &AppState) {
/// Auto-start ComfyUI on app launch (called from setup)
pub fn auto_start_comfyui(state: &AppState) {
+ // If user configured a remote host, don't try to auto-start anything locally.
+ {
+ let host = state.comfy_host.lock().unwrap().clone();
+ if !is_local_host(&host) {
+ println!("[ComfyUI] Remote host configured ({}), skipping local auto-start", host);
+ return;
+ }
+ }
+
// Always try to find and store the ComfyUI path (needed for downloads)
if state.comfy_path.lock().unwrap().is_none() {
if let Some(path) = find_comfyui_path() {
diff --git a/src-tauri/src/commands/remote.rs b/src-tauri/src/commands/remote.rs
index bf86b097..10866346 100644
--- a/src-tauri/src/commands/remote.rs
+++ b/src-tauri/src/commands/remote.rs
@@ -61,6 +61,10 @@ struct RemoteState {
passcode: Arc<TokioMutex<PasscodeState>>,
ollama_port: u16,
comfy_port: u16,
+ /// Configurable ComfyUI host — mirrors AppState.comfy_host so the mobile
+ /// proxy forwards to the right machine when the user pointed LU at a
+ /// remote ComfyUI instance.
+ comfy_host: String,
permissions: Arc<TokioMutex<RemotePermissions>>,
connected_devices: Arc<TokioMutex<Vec<ConnectedDevice>>>,
tunnel_url: Arc<TokioMutex<Option<String>>>,
@@ -688,7 +692,7 @@ async fn proxy_comfyui(
}
let query = req.uri().query().map(|q| format!("?{}", q)).unwrap_or_default();
- let target = format!("http://127.0.0.1:{}{}{}", state.comfy_port, stripped_owned, query);
+ let target = format!("http://{}:{}{}{}", state.comfy_host, state.comfy_port, stripped_owned, query);
proxy_to_target(&target, req).await
}
@@ -758,10 +762,11 @@ async fn proxy_comfyui_ws(
}
}
let comfy_port = state.comfy_port;
+ let comfy_host = state.comfy_host.clone();
ws.on_upgrade(move |client_socket| async move {
use futures_util::{SinkExt, StreamExt};
- let ws_url = format!("ws://127.0.0.1:{}/ws", comfy_port);
+ let ws_url = format!("ws://{}:{}/ws", comfy_host, comfy_port);
let upstream = match tokio_tungstenite::connect_async(&ws_url).await {
Ok((stream, _)) => stream,
Err(e) => {
@@ -3307,7 +3312,7 @@ pub async fn start_remote_server(
system_prompt: Option<String>,
) -> Result<serde_json::Value, String> {
// Clone Arcs from std::sync::Mutex, then drop it before any .await
- let (jwt_secret_arc, passcode_arc, permissions_arc, devices_arc, tunnel_url_arc, dispatched_model_arc, dispatched_system_prompt_arc, port, comfy_port) = {
+ let (jwt_secret_arc, passcode_arc, permissions_arc, devices_arc, tunnel_url_arc, dispatched_model_arc, dispatched_system_prompt_arc, port, comfy_port, comfy_host) = {
let remote = state.remote.lock().map_err(|e| e.to_string())?;
if remote.handle.is_some() {
return Err("Remote server already running".into());
@@ -3316,6 +3321,7 @@ pub async fn start_remote_server(
// unwrap on a poisoned mutex would terminate the entire app. Treat
// a missing comfy_port as a non-fatal "no comfy yet" (port 0).
let comfy_port = state.comfy_port.lock().map(|g| *g).unwrap_or(0);
+ let comfy_host = state.comfy_host.lock().map(|g| g.clone()).unwrap_or_else(|_| "localhost".to_string());
(
remote.jwt_secret.clone(),
@@ -3327,6 +3333,7 @@ pub async fn start_remote_server(
remote.dispatched_system_prompt.clone(),
remote.port,
comfy_port,
+ comfy_host,
)
}; // std::sync::MutexGuard dropped here
@@ -3368,6 +3375,7 @@ pub async fn start_remote_server(
passcode: passcode_arc,
ollama_port: 11434,
comfy_port,
+ comfy_host,
permissions: permissions_arc,
connected_devices: devices_arc,
tunnel_url: tunnel_url_arc,
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 8b75fb8c..3a2a8249 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -29,6 +29,7 @@ fn main() {
commands::process::find_comfyui,
commands::process::set_comfyui_path,
commands::process::set_comfyui_port,
+ commands::process::set_comfyui_host,
// Installation
commands::install::install_comfyui,
commands::install::install_comfyui_status,
diff --git a/src-tauri/src/state.rs b/src-tauri/src/state.rs
index d19dfdec..4340b3c2 100644
--- a/src-tauri/src/state.rs
+++ b/src-tauri/src/state.rs
@@ -41,10 +41,43 @@ impl Default for InstallState {
}
}
+/// Read persisted ComfyUI port + host from %APPDATA%/locally-uncensored/config.json.
+/// Returns (port, host) with sensible defaults (8188, "localhost") on any error.
+/// Called at startup so user-configured values survive app restarts.
+pub(crate) fn load_comfy_config_values() -> (u16, String) {
+ let mut port = 8188u16;
+ let mut host = "localhost".to_string();
+
+ if let Some(config_dir) = dirs::config_dir() {
+ let config_file = config_dir.join("locally-uncensored").join("config.json");
+ if let Ok(raw) = std::fs::read_to_string(&config_file) {
+ if let Ok(v) = serde_json::from_str::<serde_json::Value>(&raw) {
+ if let Some(p) = v.get("comfyui_port").and_then(|x| x.as_u64()) {
+ if p > 0 && p < 65536 {
+ port = p as u16;
+ }
+ }
+ if let Some(h) = v.get("comfyui_host").and_then(|x| x.as_str()) {
+ let trimmed = h.trim();
+ if !trimmed.is_empty() {
+ host = trimmed.to_string();
+ }
+ }
+ }
+ }
+ }
+
+ (port, host)
+}
+
pub struct AppState {
pub comfy_process: Mutex<Option<Child>>,
pub comfy_path: Mutex<Option<String>>,
pub comfy_port: Mutex<u16>,
+ /// Configurable ComfyUI host. Default "localhost". Setting this to a
+ /// remote hostname/IP lets users point LU at a ComfyUI running on
+ /// another machine (homelab, Docker, LAN). Persisted in config.json.
+ pub comfy_host: Mutex<String>,
pub whisper: Arc<Mutex<WhisperServer>>,
pub downloads: Arc<Mutex<HashMap<String, DownloadProgress>>>,
pub download_tokens: Arc<Mutex<HashMap<String, CancellationToken>>>,
@@ -66,10 +99,22 @@ impl AppState {
let python_bin = get_python_bin();
println!("[Python] Resolved: {}", python_bin);
+ // Load persisted ComfyUI port+host from config.json if available.
+ // Fixes a pre-existing bug where `set_comfyui_port` wrote to disk but
+ // startup never read it back. Same loader now handles the new host field.
+ let (initial_port, initial_host) = load_comfy_config_values();
+ if initial_port != 8188 {
+ println!("[ComfyUI] Loaded persisted port: {}", initial_port);
+ }
+ if initial_host != "localhost" {
+ println!("[ComfyUI] Loaded persisted host: {}", initial_host);
+ }
+
Self {
comfy_process: Mutex::new(None),
comfy_path: Mutex::new(None),
- comfy_port: Mutex::new(8188),
+ comfy_port: Mutex::new(initial_port),
+ comfy_host: Mutex::new(initial_host),
whisper: Arc::new(Mutex::new(WhisperServer::new())),
downloads: Arc::new(Mutex::new(HashMap::new())),
download_tokens: Arc::new(Mutex::new(HashMap::new())),
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index f9eac4cf..832a6f94 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/crates/tauri-cli/schema.json",
"productName": "Locally Uncensored",
- "version": "2.3.5",
+ "version": "2.3.6",
"identifier": "com.purpledoubled.locally-uncensored",
"build": {
"beforeBuildCommand": "npm run build",
diff --git a/src/api/__tests__/backend-urls.test.ts b/src/api/__tests__/backend-urls.test.ts
index c026c317..b958dc7c 100644
--- a/src/api/__tests__/backend-urls.test.ts
+++ b/src/api/__tests__/backend-urls.test.ts
@@ -15,6 +15,9 @@ import {
comfyuiWsUrl,
setComfyPort,
getComfyPort,
+ setComfyHost,
+ getComfyHost,
+ isComfyLocal,
} from '../backend'
describe('backend — URL helpers', () => {
@@ -22,12 +25,14 @@ describe('backend — URL helpers', () => {
delete windowMock.__TAURI__
delete windowMock.__TAURI_INTERNALS__
setComfyPort(8188)
+ setComfyHost('localhost')
})
afterEach(() => {
delete windowMock.__TAURI__
delete windowMock.__TAURI_INTERNALS__
setComfyPort(8188)
+ setComfyHost('localhost')
})
// ─── isTauri ───
@@ -178,4 +183,108 @@ describe('backend — URL helpers', () => {
expect(comfyuiWsUrl()).toBe('ws://localhost:4444/ws')
})
})
+
+ // ─── setComfyHost / getComfyHost / comfyuiUrl with remote host ───
+
+ describe('setComfyHost / getComfyHost', () => {
+ it('default host is localhost', () => {
+ setComfyHost('localhost')
+ expect(getComfyHost()).toBe('localhost')
+ })
+
+ it('stores and retrieves custom host', () => {
+ setComfyHost('server-1.lan')
+ expect(getComfyHost()).toBe('server-1.lan')
+ })
+
+ it('stores and retrieves IPv4 host', () => {
+ setComfyHost('192.168.1.50')
+ expect(getComfyHost()).toBe('192.168.1.50')
+ })
+
+ it('empty/whitespace falls back to localhost so URLs stay valid', () => {
+ setComfyHost('')
+ expect(getComfyHost()).toBe('localhost')
+ setComfyHost(' ')
+ expect(getComfyHost()).toBe('localhost')
+ })
+
+ it('trims whitespace when setting host', () => {
+ setComfyHost(' server-1 ')
+ expect(getComfyHost()).toBe('server-1')
+ })
+
+ it('host change affects comfyuiUrl in Tauri mode', () => {
+ windowMock.__TAURI__ = {}
+ setComfyHost('server-1.lan')
+ setComfyPort(8188)
+ expect(comfyuiUrl('/prompt')).toBe('http://server-1.lan:8188/prompt')
+ })
+
+ it('host change affects comfyuiWsUrl', () => {
+ setComfyHost('192.168.1.50')
+ setComfyPort(8188)
+ expect(comfyuiWsUrl()).toBe('ws://192.168.1.50:8188/ws')
+ })
+
+ it('host + port combined', () => {
+ windowMock.__TAURI__ = {}
+ setComfyHost('server-1.lan')
+ setComfyPort(9999)
+ expect(comfyuiUrl('/prompt')).toBe('http://server-1.lan:9999/prompt')
+ expect(comfyuiWsUrl()).toBe('ws://server-1.lan:9999/ws')
+ })
+
+ it('dev mode still uses /comfyui proxy regardless of host', () => {
+ delete windowMock.__TAURI__
+ setComfyHost('remote-server')
+ expect(comfyuiUrl('/prompt')).toBe('/comfyui/prompt')
+ })
+ })
+
+ // ─── isComfyLocal ───
+
+ describe('isComfyLocal', () => {
+ it('returns true for localhost', () => {
+ setComfyHost('localhost')
+ expect(isComfyLocal()).toBe(true)
+ })
+
+ it('returns true for 127.0.0.1', () => {
+ setComfyHost('127.0.0.1')
+ expect(isComfyLocal()).toBe(true)
+ })
+
+ it('returns true for ::1 (IPv6 loopback)', () => {
+ setComfyHost('::1')
+ expect(isComfyLocal()).toBe(true)
+ })
+
+ it('returns true for 0.0.0.0 (wildcard)', () => {
+ setComfyHost('0.0.0.0')
+ expect(isComfyLocal()).toBe(true)
+ })
+
+ it('returns false for LAN IP', () => {
+ setComfyHost('192.168.1.50')
+ expect(isComfyLocal()).toBe(false)
+ })
+
+ it('returns false for hostname', () => {
+ setComfyHost('server-1.lan')
+ expect(isComfyLocal()).toBe(false)
+ })
+
+ it('returns false for Docker service name', () => {
+ setComfyHost('comfyui-service')
+ expect(isComfyLocal()).toBe(false)
+ })
+
+ it('is case-insensitive for localhost', () => {
+ setComfyHost('LOCALHOST')
+ expect(isComfyLocal()).toBe(true)
+ setComfyHost('Localhost')
+ expect(isComfyLocal()).toBe(true)
+ })
+ })
})
diff --git a/src/api/backend.ts b/src/api/backend.ts
index 7cb40f27..0fd30db2 100644
--- a/src/api/backend.ts
+++ b/src/api/backend.ts
@@ -159,6 +159,7 @@ export async function backendCall<T = any>(
install_ollama: { path: "/local-api/install-ollama", method: "POST" },
install_ollama_status: { path: "/local-api/install-ollama-status" },
set_comfyui_port: { path: "/local-api/set-comfyui-port", method: "POST" },
+ set_comfyui_host: { path: "/local-api/set-comfyui-host", method: "POST" },
install_custom_node: { path: "/local-api/install-custom-node", method: "POST" },
whisper_status: { path: "/local-api/transcribe-status" },
transcribe: { path: "/local-api/transcribe", method: "POST" },
@@ -261,17 +262,35 @@ let _comfyPort = 8188;
export function setComfyPort(port: number) { _comfyPort = port; }
export function getComfyPort(): number { return _comfyPort; }
+/**
+ * Configurable ComfyUI host — default "localhost".
+ * Can be set to any hostname/IP so users can point LU at a remote ComfyUI
+ * (e.g. headless server, Docker container on another box, LAN machine).
+ * When the host is non-local, Settings hides Start/Stop/Restart controls
+ * because LU can't manage the lifecycle of a remote Python process.
+ */
+let _comfyHost = 'localhost';
+export function setComfyHost(host: string) {
+ // Never allow empty — that would produce "http://:8188" which breaks fetch.
+ _comfyHost = (host && host.trim()) ? host.trim() : 'localhost';
+}
+export function getComfyHost(): string { return _comfyHost; }
+export function isComfyLocal(): boolean {
+ const h = _comfyHost.toLowerCase();
+ return h === 'localhost' || h === '127.0.0.1' || h === '::1' || h === '0.0.0.0';
+}
+
/** Get the base URL for ComfyUI API calls */
export function comfyuiUrl(path: string): string {
if (isTauri()) {
- return `http://localhost:${_comfyPort}${path}`;
+ return `http://${_comfyHost}:${_comfyPort}${path}`;
}
return `/comfyui${path}`;
}
/** Get the WebSocket URL for ComfyUI */
export function comfyuiWsUrl(): string {
- return `ws://localhost:${_comfyPort}/ws`;
+ return `ws://${_comfyHost}:${_comfyPort}/ws`;
}
/** Download a ComfyUI output file — works in both dev and Tauri mode */
diff --git a/src/api/providers/openai-provider.ts b/src/api/providers/openai-provider.ts
index a15b3b62..3e0baecf 100644
--- a/src/api/providers/openai-provider.ts
+++ b/src/api/providers/openai-provider.ts
@@ -16,6 +16,24 @@ import type {
import { ProviderError } from './types'
import { parseSSEStream } from '../sse'
import { repairJson } from '../../lib/tool-call-repair'
+import { localFetch, localFetchStream } from '../backend'
+
+/**
+ * Local OpenAI-compat backends (LM Studio, vLLM, llama.cpp, KoboldCpp, etc.)
+ * are hit over plain HTTP on localhost. From the Tauri webview that triggers
+ * CORS, so use `localFetch`/`localFetchStream` which bypass via the Rust
+ * proxy (with direct-fetch fallback).
+ * Cloud endpoints (OpenAI, OpenRouter, Groq, Together, etc.) don't need the
+ * proxy and skip it via a simple host check.
+ */
+function isLocalUrl(baseUrl: string): boolean {
+ try {
+ const h = new URL(baseUrl).hostname.toLowerCase()
+ return h === 'localhost' || h === '127.0.0.1' || h === '::1' || h === '0.0.0.0'
+ } catch {
+ return false
+ }
+}
// ── OpenAI API Types ───────────────────────────────────────────
@@ -114,22 +132,23 @@ export class OpenAIProvider implements ProviderClient {
if (options?.thinking === true) body.reasoning_effort = 'high'
else if (options?.thinking === false) body.reasoning_effort = 'minimal'
- let res = await fetch(`${this.baseUrl}/chat/completions`, {
+ const fetcher = isLocalUrl(this.baseUrl) ? localFetchStream : fetch
+ let res = await fetcher(`${this.baseUrl}/chat/completions`, {
method: 'POST',
headers: this.headers,
body: JSON.stringify(body),
signal: options?.signal,
- })
+ } as any)
// Retry without reasoning_effort if the model/endpoint rejects it.
if (!res.ok && res.status === 400 && 'reasoning_effort' in body) {
delete body.reasoning_effort
- res = await fetch(`${this.baseUrl}/chat/completions`, {
+ res = await fetcher(`${this.baseUrl}/chat/completions`, {
method: 'POST',
headers: this.headers,
body: JSON.stringify(body),
signal: options?.signal,
- })
+ } as any)
}
if (!res.ok) {
@@ -215,21 +234,22 @@ export class OpenAIProvider implements ProviderClient {
if (options?.thinking === true) body.reasoning_effort = 'high'
else if (options?.thinking === false) body.reasoning_effort = 'minimal'
- let res = await fetch(`${this.baseUrl}/chat/completions`, {
+ const fetcher = isLocalUrl(this.baseUrl) ? localFetch : fetch
+ let res = await fetcher(`${this.baseUrl}/chat/completions`, {
method: 'POST',
headers: this.headers,
body: JSON.stringify(body),
signal: options?.signal,
- })
+ } as any)
if (!res.ok && res.status === 400 && 'reasoning_effort' in body) {
delete body.reasoning_effort
- res = await fetch(`${this.baseUrl}/chat/completions`, {
+ res = await fetcher(`${this.baseUrl}/chat/completions`, {
method: 'POST',
headers: this.headers,
body: JSON.stringify(body),
signal: options?.signal,
- })
+ } as any)
}
if (!res.ok) {
@@ -254,9 +274,10 @@ export class OpenAIProvider implements ProviderClient {
}
async listModels(): Promise<ProviderModel[]> {
- const res = await fetch(`${this.baseUrl}/models`, {
+ const fetcher = isLocalUrl(this.baseUrl) ? localFetch : fetch
+ const res = await fetcher(`${this.baseUrl}/models`, {
headers: this.headers,
- })
+ } as any)
if (!res.ok) {
throw await this.parseError(res)
@@ -277,9 +298,10 @@ export class OpenAIProvider implements ProviderClient {
async checkConnection(): Promise<boolean> {
try {
- const res = await fetch(`${this.baseUrl}/models`, {
+ const fetcher = isLocalUrl(this.baseUrl) ? localFetch : fetch
+ const res = await fetcher(`${this.baseUrl}/models`, {
headers: this.headers,
- })
+ } as any)
return res.ok
} catch {
return false
diff --git a/src/components/settings/SettingsPage.tsx b/src/components/settings/SettingsPage.tsx
index 9b425b9e..fbe9b546 100644
--- a/src/components/settings/SettingsPage.tsx
+++ b/src/components/settings/SettingsPage.tsx
@@ -105,21 +105,30 @@ function WorkflowSection() {
// ── ComfyUI Settings ────────────────────────────────────────────
function ComfyUISettings() {
- const [status, setStatus] = useState<{ running: boolean; found: boolean; path?: string; port?: number; starting?: boolean } | null>(null)
+ const [status, setStatus] = useState<{ running: boolean; found: boolean; path?: string; port?: number; host?: string; isLocal?: boolean; starting?: boolean } | null>(null)
const [loading, setLoading] = useState(true)
const [customPath, setCustomPath] = useState('')
const [pathError, setPathError] = useState('')
const [pathSuccess, setPathSuccess] = useState(false)
const [customPort, setCustomPort] = useState('')
const [portSuccess, setPortSuccess] = useState(false)
+ const [customHost, setCustomHost] = useState('')
+ const [hostError, setHostError] = useState('')
+ const [hostSuccess, setHostSuccess] = useState(false)
useEffect(() => {
let cancelled = false
const check = async () => {
try {
- const { backendCall } = await import('../../api/backend')
+ const { backendCall, setComfyPort, setComfyHost } = await import('../../api/backend')
const s: any = await backendCall('comfyui_status')
- if (!cancelled) setStatus(s)
+ if (!cancelled) {
+ setStatus(s)
+ // Mirror backend truth into the frontend URL builder so subsequent
+ // fetch() calls hit the right machine immediately — no restart needed.
+ if (typeof s?.port === 'number' && s.port > 0) setComfyPort(s.port)
+ if (typeof s?.host === 'string' && s.host.trim()) setComfyHost(s.host)
+ }
} catch {}
if (!cancelled) setLoading(false)
}
@@ -176,7 +185,49 @@ function ComfyUISettings() {
</div>
</div>
- {/* Path - editable */}
+ {/* Host - editable (supports remote ComfyUI: Docker, LAN, homelab) */}
+ <div className="space-y-1">
+ <span className="text-[0.7rem] text-gray-700 dark:text-gray-400">Host</span>
+ <div className="flex gap-1.5">
+ <input
+ type="text"
+ value={customHost || status?.host || 'localhost'}
+ onChange={e => { setCustomHost(e.target.value); setHostError(''); setHostSuccess(false) }}
+ placeholder="localhost or server-ip"
+ className="flex-1 px-2 py-1 rounded-lg border text-[0.6rem] font-mono bg-transparent border-white/10 text-gray-300 focus:outline-none focus:border-white/25"
+ />
+ <button
+ onClick={async () => {
+ const host = customHost.trim()
+ if (!host) { setHostError('Host required'); return }
+ setHostError('')
+ setHostSuccess(false)
+ try {
+ const { backendCall, setComfyHost } = await import('../../api/backend')
+ await backendCall('set_comfyui_host', { host })
+ setComfyHost(host)
+ setHostSuccess(true)
+ setStatus(prev => prev ? { ...prev, host, isLocal: ['localhost', '127.0.0.1', '::1', '0.0.0.0'].includes(host.toLowerCase()) } : null)
+ setTimeout(() => setHostSuccess(false), 3000)
+ } catch (err) {
+ setHostError(err instanceof Error ? err.message : 'Invalid host')
+ }
+ }}
+ disabled={!customHost.trim() || customHost.trim() === status?.host}
+ className="px-2 py-1 rounded text-[0.6rem] bg-purple-500/10 text-purple-400 hover:bg-purple-500/20 transition-colors disabled:opacity-30"
+ >
+ Set
+ </button>
+ </div>
+ {hostError && <p className="text-[0.55rem] text-red-400">{hostError}</p>}
+ {hostSuccess && <p className="text-[0.55rem] text-green-400">Host saved. Restart ComfyUI to apply.</p>}
+ {status?.host && !status?.isLocal && (
+ <p className="text-[0.55rem] text-amber-400">Remote ComfyUI — start/stop/install not available from LU. Manage the process on the server.</p>
+ )}
+ </div>
+
+ {/* Path - editable (LOCAL ONLY: remote ComfyUI manages its own path) */}
+ {status?.isLocal !== false && (
<div className="space-y-1">
<span className="text-[0.7rem] text-gray-700 dark:text-gray-400">Path</span>
<div className="flex gap-1.5">
@@ -198,6 +249,7 @@ function ComfyUISettings() {
{pathError && <p className="text-[0.55rem] text-red-400">{pathError}</p>}
{pathSuccess && <p className="text-[0.55rem] text-green-400">Path set successfully</p>}
</div>
+ )}
{/* Port - editable */}
<div className="space-y-1">
@@ -231,7 +283,8 @@ function ComfyUISettings() {
{portSuccess && <p className="text-[0.55rem] text-green-400">Port saved. Restart ComfyUI to apply.</p>}
</div>
- {/* Controls */}
+ {/* Controls — local host only (can't manage a remote process) */}
+ {status?.isLocal !== false && (
<div className="flex items-center gap-1.5">
{status?.found && !status.running && (
<button onClick={handleStart} className="px-2 py-1 rounded text-[0.6rem] bg-green-500/10 text-green-400 hover:bg-green-500/20 transition-colors">
@@ -265,6 +318,7 @@ function ComfyUISettings() {
</button>
)}
</div>
+ )}
</div>
)
}