Skip to content

fix(rag): route remote embeddings through platform fetch#431

Open
codedogQBY wants to merge 1 commit into
mainfrom
codex/fix-remote-embedding-cors
Open

fix(rag): route remote embeddings through platform fetch#431
codedogQBY wants to merge 1 commit into
mainfrom
codex/fix-remote-embedding-cors

Conversation

@codedogQBY

Copy link
Copy Markdown
Owner

Summary

  • Add a shared remote embedding request helper that uses getPlatformService().fetch() by default, falling back to browser fetch only when the platform service is unavailable.
  • Route book vectorization remote embedding batches through the helper so desktop uses Tauri HTTP instead of WebView fetch.
  • Route the desktop Vector Model settings “Test” request through the same helper so local Ollama endpoints can be validated without CORS preflight failures.

Analysis

Issue #398 happens because remote embedding requests to local Ollama were made with WebView/browser fetch from the tauri.localhost origin. Ollama rejects that CORS preflight, so ReadAny reports failed to fetch even though the local service is reachable.

The desktop app already registers TauriPlatformService, whose fetch implementation uses @tauri-apps/plugin-http and is not subject to WebView CORS. This change moves remote embedding requests onto that platform abstraction while preserving the existing OpenAI-compatible and Ollama /api/embed request/response shapes, batch truncation, and per-chunk retry behavior.

Fixes #398

Verification

  • git diff --cached --check
  • pnpm exec biome check packages/core/src/rag/remote-embedding.ts packages/core/src/rag/remote-embedding.test.ts packages/core/src/rag/index.ts packages/core/src/rag/vectorize-trigger.ts packages/app/src/components/settings/VectorModelSettings.tsx
  • pnpm --filter @readany/core test -- remote-embedding
  • pnpm --filter @readany/core exec tsc --noEmit
  • pnpm --filter app exec tsc --noEmit

@codedogQBY codedogQBY added bug Something isn't working priority:p1 High: important feature broken or major platform/workflow regression area:ai AI, model configuration, vectorization, citations, prompts area:desktop Desktop, Tauri, Windows, macOS, Linux labels Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ai AI, model configuration, vectorization, citations, prompts area:desktop Desktop, Tauri, Windows, macOS, Linux bug Something isn't working priority:p1 High: important feature broken or major platform/workflow regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Remote Embedding fails with CORS error when using local Ollama

1 participant