mirror of
				https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
				synced 2025-11-04 16:23:41 +08:00 
			
		
		
		
	feat: close #2621 use better default api url
This commit is contained in:
		@@ -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("/");
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user