| 1 | import { NextResponse } from "next/server"; |
| 2 | |
| 3 | export const dynamic = "force-dynamic"; |
| 4 | export const runtime = "nodejs"; |
| 5 | |
| 6 | export async function GET() { |
| 7 | const token = process.env.DARWIN_TERM_TOKEN ?? ""; |
| 8 | const host = process.env.DARWIN_TERM_HOST ?? "REDACTED-IP:9894"; |
| 9 | if (!token) return NextResponse.json({ error: "no token" }, { status: 503 }); |
| 10 | try { |
| 11 | const res = await fetch( |
| 12 | `http://${host}/targets?token=${encodeURIComponent(token)}`, |
| 13 | { cache: "no-store" } |
| 14 | ); |
| 15 | const body = await res.text(); |
| 16 | return new NextResponse(body, { |
| 17 | status: res.status, |
| 18 | headers: { "content-type": "application/json", "cache-control": "no-store" }, |
| 19 | }); |
| 20 | } catch (e) { |
| 21 | return NextResponse.json({ error: String(e) }, { status: 502 }); |
| 22 | } |
| 23 | } |