@lobehub/chat
Version:
Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.
18 lines (15 loc) • 584 B
text/typescript
import { NextResponse } from 'next/server';
import { ssrfSafeFetch } from 'ssrf-safe-fetch';
/**
* just for a proxy
*/
export const POST = async (req: Request) => {
const url = await req.text();
try {
const res = await ssrfSafeFetch(url);
return new Response(await res.arrayBuffer(), { headers: { ...res.headers } });
} catch (err) {
console.error(err); // DNS lookup 127.0.0.1(family:4, host:127.0.0.1.nip.io) is not allowed. Because, It is private IP address.
return NextResponse.json({ error: 'Not support internal host proxy' }, { status: 400 });
}
};