mirror of
https://github.com/open-jarvis/OpenJarvis.git
synced 2026-07-28 14:07:55 +00:00
The desktop app's chat-completions stream relies on a raw browser fetch from the Tauri webview to the FastAPI backend, so it is subject to CORS. The default allowlist only contained `tauri://localhost`, which is the production webview origin on macOS, Linux, and iOS. On Windows and Android, Tauri 2 serves the app from `http://tauri.localhost` (or `https://tauri.localhost` when `windows.useHttpsScheme` is enabled), so the preflight for `POST /v1/chat/completions` was rejected and the streaming fetch threw `TypeError: Failed to fetch` before any byte was read. Symptom users reported: in the Logs tab the request appears to succeed up to "Request sent", followed immediately by "Stream error: Failed to fetch" and "Response: 22 chars" -- which is exactly the length of the synthesized fallback string `Error: Failed to fetch` written by InputArea.tsx when streamChat throws. Add `http://tauri.localhost` and `https://tauri.localhost` to both default origin lists (`ServerConfig.cors_origins` and the `create_app` fallback), and add a regression test that drives a real preflight against `/v1/chat/completions` for each of the three Tauri origin schemes. Browser model loading kept working because it is routed through the Rust `tauriInvoke('fetch_models')` command, which is a server-to-server HTTP call not subject to browser CORS -- only streaming chat goes through the webview's fetch.