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

chore: rename CC compatible feature flag

R.D.32dc3b36abb6
diff --git a/src/app/(dashboard)/dashboard/providers/page.tsx b/src/app/(dashboard)/dashboard/providers/page.tsx
index bd0bc0d86d..2aaf2fd2ed 100644
--- a/src/app/(dashboard)/dashboard/providers/page.tsx
+++ b/src/app/(dashboard)/dashboard/providers/page.tsx
@@ -21,7 +21,6 @@ import {
isClaudeCodeCompatibleProvider,
isOpenAICompatibleProvider,
} from "@/shared/constants/providers";
-import { CC_COMPATIBLE_PROVIDER_ENABLED } from "@/shared/utils/featureFlags";
import Link from "next/link";
import { getErrorCode, getRelativeTime } from "@/shared/utils";
import { useNotificationStore } from "@/store/notificationStore";
@@ -102,6 +101,7 @@ function getConnectionErrorTag(connection) {
export default function ProvidersPage() {
const [connections, setConnections] = useState<any[]>([]);
const [providerNodes, setProviderNodes] = useState<any[]>([]);
+ const [ccCompatibleProviderEnabled, setCcCompatibleProviderEnabled] = useState(false);
const [expirations, setExpirations] = useState<any>(null);
const [loading, setLoading] = useState(true);
const [showAddCompatibleModal, setShowAddCompatibleModal] = useState(false);
@@ -126,7 +126,10 @@ export default function ProvidersPage() {
const nodesData = await nodesRes.json();
const expirationsData = await expirationsRes.json();
if (connectionsRes.ok) setConnections(connectionsData.connections || []);
- if (nodesRes.ok) setProviderNodes(nodesData.nodes || []);
+ if (nodesRes.ok) {
+ setProviderNodes(nodesData.nodes || []);
+ setCcCompatibleProviderEnabled(nodesData.ccCompatibleProviderEnabled === true);
+ }
if (expirationsRes.ok && expirationsData) setExpirations(expirationsData);
} catch (error) {
console.log("Error fetching data:", error);
@@ -514,7 +517,7 @@ export default function ProvidersPage() {
{testingMode === "compatible" ? t("testing") : t("testAll")}
</button>
)}
- {CC_COMPATIBLE_PROVIDER_ENABLED && (
+ {ccCompatibleProviderEnabled && (
<Button
size="sm"
variant="secondary"
@@ -583,7 +586,7 @@ export default function ProvidersPage() {
setShowAddAnthropicCompatibleModal(false);
}}
/>
- {CC_COMPATIBLE_PROVIDER_ENABLED && (
+ {ccCompatibleProviderEnabled && (
<AddCcCompatibleModal
isOpen={showAddCcCompatibleModal}
onClose={() => setShowAddCcCompatibleModal(false)}
diff --git a/src/app/api/provider-nodes/route.ts b/src/app/api/provider-nodes/route.ts
index bc712284dd..f8978e7ad2 100644
--- a/src/app/api/provider-nodes/route.ts
+++ b/src/app/api/provider-nodes/route.ts
@@ -29,7 +29,10 @@ function sanitizeAnthropicBaseUrl(baseUrl: string) {
export async function GET() {
try {
const nodes = await getProviderNodes();
- return NextResponse.json({ nodes });
+ return NextResponse.json({
+ nodes,
+ ccCompatibleProviderEnabled: isCcCompatibleProviderEnabled(),
+ });
} catch (error) {
console.log("Error fetching provider nodes:", error);
return NextResponse.json({ error: "Failed to fetch provider nodes" }, { status: 500 });
diff --git a/src/shared/utils/featureFlags.ts b/src/shared/utils/featureFlags.ts
index 449da7e88f..7679f2152d 100644
--- a/src/shared/utils/featureFlags.ts
+++ b/src/shared/utils/featureFlags.ts
@@ -1,5 +1,3 @@
export function isCcCompatibleProviderEnabled() {
- return process.env.NEXT_PUBLIC_ENABLE_CC_COMPATIBLE_PROVIDER === "true";
+ return process.env.ENABLE_CC_COMPATIBLE_PROVIDER === "true";
}
-
-export const CC_COMPATIBLE_PROVIDER_ENABLED = isCcCompatibleProviderEnabled();
diff --git a/tests/unit/cc-compatible-provider.test.mjs b/tests/unit/cc-compatible-provider.test.mjs
index 797928f155..dd20e74f64 100644
--- a/tests/unit/cc-compatible-provider.test.mjs
+++ b/tests/unit/cc-compatible-provider.test.mjs
@@ -21,7 +21,7 @@ const providerNodesValidateRoute =
await import("../../src/app/api/provider-nodes/validate/route.ts");
const originalFetch = globalThis.fetch;
-const originalFlag = process.env.NEXT_PUBLIC_ENABLE_CC_COMPATIBLE_PROVIDER;
+const originalFlag = process.env.ENABLE_CC_COMPATIBLE_PROVIDER;
async function resetStorage() {
core.resetDbInstance();
@@ -32,9 +32,9 @@ async function resetStorage() {
test.afterEach(async () => {
globalThis.fetch = originalFetch;
if (originalFlag === undefined) {
- delete process.env.NEXT_PUBLIC_ENABLE_CC_COMPATIBLE_PROVIDER;
+ delete process.env.ENABLE_CC_COMPATIBLE_PROVIDER;
} else {
- process.env.NEXT_PUBLIC_ENABLE_CC_COMPATIBLE_PROVIDER = originalFlag;
+ process.env.ENABLE_CC_COMPATIBLE_PROVIDER = originalFlag;
}
await resetStorage();
});
@@ -42,9 +42,9 @@ test.afterEach(async () => {
test.after(() => {
globalThis.fetch = originalFetch;
if (originalFlag === undefined) {
- delete process.env.NEXT_PUBLIC_ENABLE_CC_COMPATIBLE_PROVIDER;
+ delete process.env.ENABLE_CC_COMPATIBLE_PROVIDER;
} else {
- process.env.NEXT_PUBLIC_ENABLE_CC_COMPATIBLE_PROVIDER = originalFlag;
+ process.env.ENABLE_CC_COMPATIBLE_PROVIDER = originalFlag;
}
core.resetDbInstance();
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
@@ -170,7 +170,7 @@ test("validateProviderApiKey uses CC skeleton request after /models fallback", a
});
test("provider-nodes create route rejects CC mode when feature flag is disabled", async () => {
- delete process.env.NEXT_PUBLIC_ENABLE_CC_COMPATIBLE_PROVIDER;
+ delete process.env.ENABLE_CC_COMPATIBLE_PROVIDER;
const response = await providerNodesRoute.POST(
new Request("http://localhost/api/provider-nodes", {
@@ -190,7 +190,7 @@ test("provider-nodes create route rejects CC mode when feature flag is disabled"
});
test("provider-nodes create route creates CC node with dedicated prefix when enabled", async () => {
- process.env.NEXT_PUBLIC_ENABLE_CC_COMPATIBLE_PROVIDER = "true";
+ process.env.ENABLE_CC_COMPATIBLE_PROVIDER = "true";
const response = await providerNodesRoute.POST(
new Request("http://localhost/api/provider-nodes", {
@@ -217,7 +217,7 @@ test("provider-nodes create route creates CC node with dedicated prefix when ena
});
test("provider-nodes validate route rejects CC mode when feature flag is disabled", async () => {
- delete process.env.NEXT_PUBLIC_ENABLE_CC_COMPATIBLE_PROVIDER;
+ delete process.env.ENABLE_CC_COMPATIBLE_PROVIDER;
const response = await providerNodesValidateRoute.POST(
new Request("http://localhost/api/provider-nodes/validate", {
@@ -234,3 +234,13 @@ test("provider-nodes validate route rejects CC mode when feature flag is disable
assert.equal(response.status, 403);
});
+
+test("provider-nodes list route exposes CC flag state from server env", async () => {
+ process.env.ENABLE_CC_COMPATIBLE_PROVIDER = "true";
+
+ const response = await providerNodesRoute.GET();
+ assert.equal(response.status, 200);
+
+ const data = await response.json();
+ assert.equal(data.ccCompatibleProviderEnabled, true);
+});