13 lines
666 B
TypeScript
13 lines
666 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { backendFetch, readBackendError } from "@/lib/backend";
|
|
|
|
export const runtime = "nodejs";
|
|
|
|
export async function POST(request: NextRequest, context: { params: Promise<{ conversationId: string }> }) {
|
|
const { conversationId } = await context.params;
|
|
const body = await request.formData();
|
|
const response = await backendFetch(`/v1/conversations/${encodeURIComponent(conversationId)}/attachments`, { method: "POST", body });
|
|
if (!response.ok) return NextResponse.json({ error: await readBackendError(response) }, { status: response.status });
|
|
return NextResponse.json(await response.json());
|
|
}
|