From 34e70873fc6e939cc26d5e6ab45f38164c57bbac Mon Sep 17 00:00:00 2001 From: Agent Relay Date: Thu, 8 Jan 2026 21:47:26 +0000 Subject: [PATCH] fix: Use cloud-aware routing for file autocomplete API calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FileAutocomplete was making direct fetch to /api/files without using getApiUrl(), which bypasses the workspace proxy in cloud mode. This caused 404 errors as requests hit the teamsRouter which doesn't have a /files route. Now uses getApiUrl() to properly route through /api/workspaces/:id/proxy/files in cloud mode while maintaining backward compatibility with apiBase prop. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/dashboard/react-components/FileAutocomplete.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dashboard/react-components/FileAutocomplete.tsx b/src/dashboard/react-components/FileAutocomplete.tsx index b51779a3..cd9ae885 100644 --- a/src/dashboard/react-components/FileAutocomplete.tsx +++ b/src/dashboard/react-components/FileAutocomplete.tsx @@ -7,6 +7,7 @@ */ import React, { useState, useCallback, useEffect, useRef, useMemo } from 'react'; +import { getApiUrl } from '../lib/api'; export interface FileAutocompleteProps { /** Current input value */ @@ -150,10 +151,11 @@ export function FileAutocomplete({ try { const searchQuery = query || ''; - const response = await fetch( - `${apiBase}/api/files?q=${encodeURIComponent(searchQuery)}&limit=15`, - { signal: controller.signal } - ); + // Use getApiUrl for cloud mode support (routes through workspace proxy) + const url = apiBase + ? `${apiBase}/api/files?q=${encodeURIComponent(searchQuery)}&limit=15` + : getApiUrl(`/api/files?q=${encodeURIComponent(searchQuery)}&limit=15`); + const response = await fetch(url, { signal: controller.signal }); if (!response.ok) { throw new Error('Failed to fetch files');