frontend: proxy /api/mcp/* → manar-mcp:8092 (exposes OAuth endpoints publicly)

This commit is contained in:
2026-05-09 08:56:56 +00:00
parent 4c0ad86b93
commit b16e7d09de
@@ -0,0 +1,49 @@
import { NextRequest, NextResponse } from 'next/server'
const MCP_URL = process.env.MANAR_MCP_URL || 'http://manar-mcp:8092'
export async function GET(
req: NextRequest,
{ params }: { params: { path: string[] } }
) {
const path = params.path.join('/')
const search = req.nextUrl.search
const upstream = `${MCP_URL}/${path}${search}`
const resp = await fetch(upstream, {
headers: { 'Content-Type': 'application/json' },
redirect: 'manual',
})
if (resp.status >= 300 && resp.status < 400) {
return NextResponse.redirect(resp.headers.get('location') || '/', resp.status)
}
const body = await resp.text()
return new NextResponse(body, {
status: resp.status,
headers: { 'Content-Type': resp.headers.get('content-type') || 'application/json' },
})
}
export async function POST(
req: NextRequest,
{ params }: { params: { path: string[] } }
) {
const path = params.path.join('/')
const search = req.nextUrl.search
const upstream = `${MCP_URL}/${path}${search}`
const body = await req.text()
const resp = await fetch(upstream, {
method: 'POST',
headers: { 'Content-Type': req.headers.get('content-type') || 'application/json' },
body,
})
const respBody = await resp.text()
return new NextResponse(respBody, {
status: resp.status,
headers: { 'Content-Type': resp.headers.get('content-type') || 'application/json' },
})
}