feat: #1640 support free gpt endpoint

This commit is contained in:
Yidadaa
2023-05-19 23:53:27 +08:00
parent e5329dc28a
commit 203ac0970d
3 changed files with 7 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
import { NextRequest } from "next/server";
const OPENAI_URL = "api.openai.com";
export const OPENAI_URL = "api.openai.com";
const DEFAULT_PROTOCOL = "https";
const PROTOCOL = process.env.PROTOCOL ?? DEFAULT_PROTOCOL;
const BASE_URL = process.env.BASE_URL ?? OPENAI_URL;
@@ -45,8 +45,8 @@ export async function requestOpenai(req: NextRequest) {
signal: controller.signal,
});
} catch (err: unknown) {
if (err instanceof Error && err.name === 'AbortError') {
console.log('Fetch aborted');
if (err instanceof Error && err.name === "AbortError") {
console.log("Fetch aborted");
} else {
throw err;
}