Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix localhost custom AI preset diagnostics fetch

Flamkic0a5c4d1f3dd
diff --git a/apps/screenpipe-app-tauri/components/settings/ai-presets.tsx b/apps/screenpipe-app-tauri/components/settings/ai-presets.tsx
index 244678118..38edd18af 100644
--- a/apps/screenpipe-app-tauri/components/settings/ai-presets.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/ai-presets.tsx
@@ -106,6 +106,16 @@ const formatPresetName = (name: string): string => {
return name;
};
+const isLocalhostUrl = (url?: string): boolean => {
+ if (!url) return false;
+ try {
+ const hostname = new URL(url).hostname.toLowerCase();
+ return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
+ } catch {
+ return false;
+ }
+};
+
type DiagnosticStatus = "pass" | "fail" | "skip" | "pending" | "running";
interface DiagnosticStepResult {
@@ -585,7 +595,11 @@ const AISection = ({
chat: { status: "running", message: "Sending test message..." },
}));
} else {
- const modelsFetchFn = fetch;
+ // Local custom providers often do not implement browser CORS preflight on /models.
+ const modelsFetchFn =
+ settingsPreset?.provider === "custom" && isLocalhostUrl(settingsPreset?.url)
+ ? tauriFetch
+ : fetch;
try {
modelsResponse = await modelsFetchFn(modelsUrl, {
headers,
@@ -832,7 +846,8 @@ const AISection = ({
break;
case "custom":
try {
- const customResponse = await fetch(
+ const customFetchFn = isLocalhostUrl(settingsPreset?.url) ? tauriFetch : fetch;
+ const customResponse = await customFetchFn(
`${settingsPreset?.url}/models`,
{
headers: settingsPreset.apiKey