28 lines
851 B
TypeScript
28 lines
851 B
TypeScript
import { getCurrentAccount } from "@/lib/claw-auth";
|
|
|
|
const CLAW_API_URL = process.env.CLAW_API_URL ?? "http://127.0.0.1:8765";
|
|
|
|
export async function GET(request: Request) {
|
|
const account = await getCurrentAccount();
|
|
if (!account) return Response.json([], { status: 401 });
|
|
|
|
const incoming = new URL(request.url);
|
|
const url = new URL(`${CLAW_API_URL}/api/sessions`);
|
|
url.searchParams.set("account_id", account.id);
|
|
const includeChildren = incoming.searchParams.get("include_children");
|
|
if (includeChildren) {
|
|
url.searchParams.set("include_children", includeChildren);
|
|
}
|
|
const response = await fetch(url, {
|
|
cache: "no-store",
|
|
});
|
|
const payload = await response.text();
|
|
return new Response(payload, {
|
|
status: response.status,
|
|
headers: {
|
|
"content-type":
|
|
response.headers.get("content-type") ?? "application/json",
|
|
},
|
|
});
|
|
}
|