Files

35 lines
1.1 KiB
TypeScript

import { NextResponse } from 'next/server';
export async function POST(req: Request) {
try {
const body = await req.json();
const { roomName } = body;
if (!roomName) {
return NextResponse.json({ error: "Room name is required" }, { status: 400 });
}
// Call the PM2 Vanguard AI webhook
// Assume Vanguard AI runs on localhost:3060 on Gamma
const response = await fetch('http://127.0.0.1:3060/api/summon', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ roomName })
});
if (!response.ok) {
const errData = await response.json().catch(() => ({}));
return NextResponse.json({ error: "Vanguard failed to join", details: errData }, { status: 500 });
}
const data = await response.json();
return NextResponse.json({ success: true, message: data.message });
} catch (err) {
console.error("Summon Vanguard Error:", err);
return NextResponse.json({ error: "Internal server error" }, { status: 500 });
}
}