fix: respect PORT env in internal model-test fetch (#1014)

Internal model test routes fetched 127.0.0.1:UPDATER_CONFIG.appPort
(hardcoded 20128). When PORT env is set to a different value, the app
listens on PORT but the internal fetch still targets 20128, causing
"fetch failed" on /api/models/test and /api/providers/[id]/test-models.

Fall back to UPDATER_CONFIG.appPort only when process.env.PORT is unset.
This commit is contained in:
Anh 2026-05-11 15:57:02 +07:00 committed by GitHub
parent 50b8a59f99
commit 06291b290f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -8,7 +8,7 @@ export async function POST(request) {
const { model, kind } = await request.json();
if (!model) return NextResponse.json({ error: "Model required" }, { status: 400 });
const baseUrl = `http://127.0.0.1:${UPDATER_CONFIG.appPort}`;
const baseUrl = `http://127.0.0.1:${process.env.PORT || UPDATER_CONFIG.appPort}`;
// Get an active internal API key for auth (if requireApiKey is enabled)
let apiKey = null;

View file

@ -65,7 +65,7 @@ export async function POST(request, { params }) {
let models = getProviderModels(alias);
const baseUrl = `http://127.0.0.1:${UPDATER_CONFIG.appPort}`;
const baseUrl = `http://127.0.0.1:${process.env.PORT || UPDATER_CONFIG.appPort}`;
// Compatible providers: fetch live model list
if (isCompatible && models.length === 0) {