● Zion Boggan
repos/Darwin/face/src/app/api/term/sessions/route.ts
zionboggan.com ↗
23 lines · typescript
History for this file →
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({ sessions: [] });
10
  try {
11
    const res = await fetch(
12
      `http://${host}/sessions?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({ sessions: [], error: String(e) }, { status: 502 });
22
  }
23
}