Skip to content

Commit

Permalink
🐛 fix: 修正 basePath 在生产环境下不生效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Aug 4, 2023
1 parent 34b1a95 commit 71b9139
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/pages/api/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { PluginsMap } from '@/plugins';
import { ErrorType } from '@/types/fetch';
import { OpenAIStreamPayload } from '@/types/openai';

const isDev = process.env.NODE_ENV === 'development';

// 创建 OpenAI 实例
export const createOpenAI = (userApiKey: string | null, endpoint?: string | null) => {
const { OPENAI_API_KEY, OPENAI_PROXY_URL } = getServerConfig();
Expand All @@ -18,10 +16,9 @@ export const createOpenAI = (userApiKey: string | null, endpoint?: string | null
apiKey: !userApiKey ? OPENAI_API_KEY : userApiKey,
});

return new OpenAIApi(
config,
endpoint ? endpoint : isDev && OPENAI_PROXY_URL ? OPENAI_PROXY_URL : undefined,
);
const basePath = endpoint ? endpoint : OPENAI_PROXY_URL ? OPENAI_PROXY_URL : undefined;

return new OpenAIApi(config, basePath);
};

interface CreateChatCompletionOptions {
Expand Down

0 comments on commit 71b9139

Please sign in to comment.