Spaces:
Running
Running
File size: 572 Bytes
5012205 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import { NextResponse } from "next/server";
import { getChats } from "@/lib/chat-store";
export async function GET(request: Request) {
try {
const userId = request.headers.get('x-user-id');
if (!userId) {
return NextResponse.json({ error: "User ID is required" }, { status: 400 });
}
const chats = await getChats(userId);
return NextResponse.json(chats);
} catch (error) {
console.error("Error fetching chats:", error);
return NextResponse.json(
{ error: "Failed to fetch chats" },
{ status: 500 }
);
}
} |