forked from XiaoMo/ChatGPT-Next-Web
feat: close #2621 use better default api url
This commit is contained in:
parent
25ada1eae9
commit
ae8226907f
@ -13,6 +13,7 @@ import {
|
||||
fetchEventSource,
|
||||
} from "@fortaine/fetch-event-source";
|
||||
import { prettyObject } from "@/app/utils/format";
|
||||
import { getClientConfig } from "@/app/config/client";
|
||||
|
||||
export interface OpenAIListModelResponse {
|
||||
object: string;
|
||||
@ -28,13 +29,16 @@ export class ChatGPTApi implements LLMApi {
|
||||
|
||||
path(path: string): string {
|
||||
let openaiUrl = useAccessStore.getState().openaiUrl;
|
||||
const apiPath = "/api/openai";
|
||||
|
||||
if (openaiUrl.length === 0) {
|
||||
openaiUrl = DEFAULT_API_HOST;
|
||||
const isApp = !!getClientConfig()?.isApp;
|
||||
openaiUrl = isApp ? DEFAULT_API_HOST : apiPath;
|
||||
}
|
||||
if (openaiUrl.endsWith("/")) {
|
||||
openaiUrl = openaiUrl.slice(0, openaiUrl.length - 1);
|
||||
}
|
||||
if (!openaiUrl.startsWith("http") && !openaiUrl.startsWith("/api/openai")) {
|
||||
if (!openaiUrl.startsWith("http") && !openaiUrl.startsWith(apiPath)) {
|
||||
openaiUrl = "https://" + openaiUrl;
|
||||
}
|
||||
return [openaiUrl, path].join("/");
|
||||
|
Loading…
Reference in New Issue
Block a user