fix(desktop): route fetch + WebSocket through native Tauri plugins (mixed-content)
Fixing VITE_API_BASE got login to build a correct absolute URL, but it still failed with WebKit's generic "Load failed" — WebKitGTK treats tauri://localhost as a secure origin, so http://127.0.0.1:3000 (and ws://) from inside it is blocked as mixed content, a WebKit limitation CSP's connect-src can't override. Added tauri-plugin-http (genuine fetch() drop-in, wired via a new platformFetch() in origin.ts, used by api.ts + logger.ts) and tauri-plugin-websocket (not a drop-in — adapted behind a native-WebSocket- shaped interface in the new platform-ws.ts so use-live-feed.ts needed no changes). Both route through Tauri's Rust side instead of the webview's own fetch/WebSocket. Capabilities scoped to 127.0.0.1:3000/localhost:3000, matching the existing CSP allowlist.
This commit is contained in:
+12
@@ -2767,3 +2767,15 @@ zero diagnostic trail. Fixed release.yml to sed-patch tauri.conf.json's version
|
||||
right before building (checked-in value is now dev-only, never hand-maintained for releases), and
|
||||
split desktop-updater.ts's catch so a real post-accept failure logs instead of vanishing. Full
|
||||
detail on [[desktop-shell-tauri]].
|
||||
|
||||
## [2026-09-03] fix | Desktop login "Load failed": WebKit mixed-content, not CORS/CSP
|
||||
|
||||
After fixing VITE_API_BASE, login still failed with WebKit's generic "Load failed" — a raw browser
|
||||
fetch() rejection with no server-side trace, since the request never reached the network. Root
|
||||
cause: WebKitGTK treats tauri://localhost as a secure origin, so http://127.0.0.1:3000 (and
|
||||
ws://127.0.0.1:3000) from inside it is blocked as mixed content — a known WebKit limitation, NOT
|
||||
fixable via CSP connect-src. Fixed by routing both through Tauri plugins that use the native (Rust)
|
||||
HTTP/WS client instead of the webview's own: tauri-plugin-http (a genuine fetch() drop-in, wired
|
||||
into api.ts/logger.ts via a new platformFetch() in origin.ts) and tauri-plugin-websocket (NOT a
|
||||
drop-in — async/listener API — adapted behind a native-WebSocket-shaped interface in the new
|
||||
platform-ws.ts so use-live-feed.ts needed no changes). Full detail on [[desktop-shell-tauri]].
|
||||
|
||||
Reference in New Issue
Block a user