remove ai plugin integration
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
import { NextRequest } from "next/server";
|
||||
import { CLOUD_BASE, FRONTEND_API_KEY } from "@/lib/cloud";
|
||||
|
||||
// Proxy the editor's AI chat requests to Frontend Cloud, injecting the API key
|
||||
// server-side so it is never exposed to the client. The cloud response is
|
||||
// streamed straight back to the caller.
|
||||
export async function POST(req: NextRequest) {
|
||||
const upstream = await fetch(`${CLOUD_BASE}/api/chat`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"content-type": req.headers.get("content-type") ?? "application/json",
|
||||
"x-api-key": FRONTEND_API_KEY,
|
||||
},
|
||||
body: req.body,
|
||||
// Required by undici when forwarding a streaming request body.
|
||||
// @ts-expect-error - duplex is valid but missing from the lib types.
|
||||
duplex: "half",
|
||||
});
|
||||
|
||||
return new Response(upstream.body, {
|
||||
status: upstream.status,
|
||||
headers: {
|
||||
"content-type":
|
||||
upstream.headers.get("content-type") ?? "application/octet-stream",
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user