当我尝试在Vercel Deployment上向我的Edge Function POST某些内容时,我收到以下错误:
[POST] /API/openai reason=EDGE_FUNCTION_INVOCATION_FAILED,status=500,user_error=true
TypeError:在app/API/openai/route.ts非法调用:12:36
我的边函数文件:
import { OpenAIStream, OpenAIStreamPayload } from "@/utils/OpenAIStream";
if (!process.env.OPENAI_API_KEY) {
throw new Error("Missing env var from OpenAI");
}
export const config = {
runtime: "edge",
};
export async function POST(request: Request) {
const { prompt } = (await request.json()) as {
prompt?: string;
};
if (!prompt) {
return new Response("No prompt in the request", { status: 400 });
}
//OpenAI logic....
return new Response();
}
1条答案
按热度按时间knpiaxh11#
这是一个已知问题,已在最新的
13.3.x
中得到修复。解决方法可在此处找到https://github.com/vercel/next.js/issues/46337#issuecomment-1478613133