fix: custom model compatibility with antigravity/mitm (PR #250)

This commit is contained in:
mxskeen
2026-03-06 16:41:02 +07:00
committed by decolua
parent d347de8092
commit 97860a0629
9 changed files with 88 additions and 41 deletions

View File

@@ -1,6 +1,8 @@
import { NextResponse } from "next/server";
import { getCombos, createCombo, getComboByName } from "@/lib/localDb";
export const dynamic = "force-dynamic";
// Validate combo name: only a-z, A-Z, 0-9, -, _
const VALID_NAME_REGEX = /^[a-zA-Z0-9_-]+$/;

View File

@@ -2,6 +2,8 @@ import { NextResponse } from "next/server";
import { getApiKeys, createApiKey } from "@/lib/localDb";
import { getConsistentMachineId } from "@/shared/utils/machineId";
export const dynamic = "force-dynamic";
// GET /api/keys - List API keys
export async function GET() {
try {

View File

@@ -1,6 +1,8 @@
import { NextResponse } from "next/server";
import { getModelAliases, setModelAlias, deleteModelAlias } from "@/models";
export const dynamic = "force-dynamic";
// GET /api/models/alias - Get all aliases
export async function GET() {
try {

View File

@@ -3,6 +3,8 @@ import { createProviderNode, getProviderNodes } from "@/models";
import { OPENAI_COMPATIBLE_PREFIX, ANTHROPIC_COMPATIBLE_PREFIX } from "@/shared/constants/providers";
import { generateId } from "@/shared/utils";
export const dynamic = "force-dynamic";
const OPENAI_COMPATIBLE_DEFAULTS = {
baseUrl: "https://api.openai.com/v1",
};

View File

@@ -3,6 +3,8 @@ import { getProviderConnections, createProviderConnection, getProviderNodeById,
import { APIKEY_PROVIDERS } from "@/shared/constants/config";
import { isOpenAICompatibleProvider, isAnthropicCompatibleProvider } from "@/shared/constants/providers";
export const dynamic = "force-dynamic";
// GET /api/providers - List all connections
export async function GET() {
try {
@@ -15,8 +17,8 @@ export async function GET() {
for (const node of nodes) {
if (node.id && node.name) nodeNameMap[node.id] = node.name;
}
} catch {}
} catch { }
// Hide sensitive fields, enrich name for compatible providers
const safeConnections = connections.map(c => {
const isCompatible = isOpenAICompatibleProvider(c.provider) || isAnthropicCompatibleProvider(c.provider);
@@ -47,9 +49,9 @@ export async function POST(request) {
const { provider, apiKey, name, priority, globalPriority, defaultModel, testStatus } = body;
// Validation
const isValidProvider = APIKEY_PROVIDERS[provider] ||
isOpenAICompatibleProvider(provider) ||
isAnthropicCompatibleProvider(provider);
const isValidProvider = APIKEY_PROVIDERS[provider] ||
isOpenAICompatibleProvider(provider) ||
isAnthropicCompatibleProvider(provider);
if (!provider || !isValidProvider) {
return NextResponse.json({ error: "Invalid provider" }, { status: 400 });