Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix: improve API base URL handling and filter for chat models in CopilotToolCard

Alptekin Gülcan8383da8a50d9
diff --git a/src/app/(dashboard)/dashboard/cli-tools/CLIToolsPageClient.tsx b/src/app/(dashboard)/dashboard/cli-tools/CLIToolsPageClient.tsx
index 15df54eb18..7f8f1c5544 100644
--- a/src/app/(dashboard)/dashboard/cli-tools/CLIToolsPageClient.tsx
+++ b/src/app/(dashboard)/dashboard/cli-tools/CLIToolsPageClient.tsx
@@ -33,7 +33,6 @@ export default function CLIToolsPageClient({ machineId }) {
const [apiKeys, setApiKeys] = useState([]);
const [toolStatuses, setToolStatuses] = useState({});
const [statusesLoaded, setStatusesLoaded] = useState(false);
- const [apiBaseUrl, setApiBaseUrl] = useState("");
useEffect(() => {
fetchConnections();
@@ -48,12 +47,6 @@ export default function CLIToolsPageClient({ machineId }) {
if (res.ok) {
const data = await res.json();
setCloudEnabled(data.cloudEnabled || false);
- if (typeof window !== "undefined") {
- const protocol = window.location.protocol;
- const hostname = window.location.hostname;
- const apiPort = data?.apiPort || 20128;
- setApiBaseUrl(`${protocol}//${hostname}:${apiPort}`);
- }
}
} catch (error) {
console.log("Error loading cloud settings:", error);
@@ -155,9 +148,8 @@ export default function CLIToolsPageClient({ machineId }) {
if (cloudEnabled && CLOUD_URL) {
return CLOUD_URL;
}
- if (apiBaseUrl) {
- return apiBaseUrl;
- }
+ // Use window.location.origin directly — works correctly in Docker/reverse-proxy
+ // Per @alpgul feedback: don't use baseUrl prop (has port duplication issues)
if (typeof window !== "undefined") {
return window.location.origin;
}
diff --git a/src/app/(dashboard)/dashboard/cli-tools/components/CopilotToolCard.tsx b/src/app/(dashboard)/dashboard/cli-tools/components/CopilotToolCard.tsx
index 21d2a73d85..24eb9778ec 100644
--- a/src/app/(dashboard)/dashboard/cli-tools/components/CopilotToolCard.tsx
+++ b/src/app/(dashboard)/dashboard/cli-tools/components/CopilotToolCard.tsx
@@ -60,7 +60,7 @@ export default function CopilotToolCard({
.then((data) => {
if (cancelled) return;
const modelList = (data.data || [])
- .filter((m: any) => m.id) // Only models with valid IDs
+ .filter((m: any) => m && !m.type && !m.parent && m.id) // Only chat models with valid IDs
.map((m: any) => ({
value: m.id,
label: m.id,
@@ -112,11 +112,8 @@ export default function CopilotToolCard({
};
const getBaseUrlForConfig = () => {
- // Use window.location.origin directly — works correctly in Docker/reverse-proxy
- // Per @alpgul feedback: don't use baseUrl prop (has port duplication issues)
- const origin =
- typeof window !== "undefined" ? window.location.origin : "http://localhost:20128";
- return `${origin}/v1/chat/completions`;
+ const url = baseUrl;
+ return `${url}/v1/chat/completions`;
};
// Generate the Copilot chatLanguageModels.json config