From 1c335a68e06ee5102375bc4f4d326b37cfb60ec8 Mon Sep 17 00:00:00 2001 From: markshawn2020 Date: Fri, 14 Jul 2023 18:10:42 +0800 Subject: [PATCH] fixed openai base url if empty --- app/api/common.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/common.ts b/app/api/common.ts index 6d6a7d1f..5222ee94 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -2,8 +2,8 @@ import { NextRequest, NextResponse } from "next/server"; 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; +const PROTOCOL = process.env.PROTOCOL || DEFAULT_PROTOCOL; +const BASE_URL = process.env.BASE_URL || OPENAI_URL; // ?? 仅在 undefined 时候才转向后者,但是环境变量大家都不会去注释掉变量,因此最好用 || const DISABLE_GPT4 = !!process.env.DISABLE_GPT4; export async function requestOpenai(req: NextRequest) {