fix: resolve WebUI API proxy ECONNREFUSED and configmap placeholder issues
Some checks failed
Build and Deploy GooSeek / build-and-deploy (push) Has been cancelled

- Fix route handlers to use API_GATEWAY_URL env var with correct K8s fallback
  instead of localhost:3015
- Replace ${} placeholders in configmap.yaml with actual static values to
  prevent kustomize from overwriting envsubst-generated config
- Separate secrets into dedicated secrets.yaml for envsubst processing
- Update deploy.sh to only envsubst secrets (configmap now has static values)

Made-with: Cursor
This commit is contained in:
home
2026-03-03 04:16:57 +03:00
parent 32102c379a
commit 1c1a10eb35
6 changed files with 92 additions and 94 deletions

View File

@@ -1,34 +1,41 @@
import { NextRequest, NextResponse } from 'next/server';
const API_URL = process.env.API_URL || 'http://localhost:3015';
const API_GATEWAY =
process.env.API_GATEWAY_URL ||
process.env.API_URL ||
'http://api-gateway:3015';
export async function POST(request: NextRequest): Promise<NextResponse> {
const targetUrl = `${API_URL}/api/chat`;
const targetUrl = `${API_GATEWAY}/api/chat`;
const headers = new Headers();
const authHeader = request.headers.get('authorization');
if (authHeader) {
headers.set('Authorization', authHeader);
}
headers.set('Content-Type', 'application/json');
headers.set('Accept', 'application/x-ndjson');
try {
const body = await request.text();
const response = await fetch(targetUrl, {
method: 'POST',
headers,
body,
});
const contentType = response.headers.get('content-type') || 'application/x-ndjson';
const contentType =
response.headers.get('content-type') || 'application/x-ndjson';
const stream = response.body;
if (!stream) {
return NextResponse.json({ error: 'No response body' }, { status: 500 });
return NextResponse.json(
{ error: 'No response body' },
{ status: 500 },
);
}
return new NextResponse(stream, {
@@ -44,7 +51,7 @@ export async function POST(request: NextRequest): Promise<NextResponse> {
console.error('[Chat API Proxy] Error:', error);
return NextResponse.json(
{ error: 'Service unavailable' },
{ status: 503 }
{ status: 503 },
);
}
}

View File

@@ -1,6 +1,9 @@
import { NextRequest, NextResponse } from 'next/server';
const API_URL = process.env.API_URL || 'http://localhost:3015';
const API_URL =
process.env.API_GATEWAY_URL ||
process.env.API_URL ||
'http://api-gateway:3015';
async function proxyRequest(
request: NextRequest,