mirror of
				https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
				synced 2025-11-04 16:23:41 +08:00 
			
		
		
		
	feat: (1) fix issues/4335 and issues/4518
This commit is contained in:
		@@ -348,7 +348,11 @@ export class ClaudeApi implements LLMApi {
 | 
				
			|||||||
  path(path: string): string {
 | 
					  path(path: string): string {
 | 
				
			||||||
    const accessStore = useAccessStore.getState();
 | 
					    const accessStore = useAccessStore.getState();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let baseUrl: string = accessStore.anthropicUrl;
 | 
					    let baseUrl: string = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (accessStore.useCustomConfig) {
 | 
				
			||||||
 | 
					      baseUrl = accessStore.anthropicUrl;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // if endpoint is empty, use default endpoint
 | 
					    // if endpoint is empty, use default endpoint
 | 
				
			||||||
    if (baseUrl.trim().length === 0) {
 | 
					    if (baseUrl.trim().length === 0) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -104,7 +104,13 @@ export class GeminiProApi implements LLMApi {
 | 
				
			|||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const accessStore = useAccessStore.getState();
 | 
					    const accessStore = useAccessStore.getState();
 | 
				
			||||||
    let baseUrl = accessStore.googleUrl;
 | 
					
 | 
				
			||||||
 | 
					    let baseUrl = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (accessStore.useCustomConfig) {
 | 
				
			||||||
 | 
					      baseUrl = accessStore.googleUrl;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const isApp = !!getClientConfig()?.isApp;
 | 
					    const isApp = !!getClientConfig()?.isApp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let shouldStream = !!options.config.stream;
 | 
					    let shouldStream = !!options.config.stream;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,16 +60,24 @@ export class ChatGPTApi implements LLMApi {
 | 
				
			|||||||
  path(path: string): string {
 | 
					  path(path: string): string {
 | 
				
			||||||
    const accessStore = useAccessStore.getState();
 | 
					    const accessStore = useAccessStore.getState();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const isAzure = accessStore.provider === ServiceProvider.Azure;
 | 
					    let baseUrl = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (isAzure && !accessStore.isValidAzure()) {
 | 
					    if (accessStore.useCustomConfig) {
 | 
				
			||||||
      throw Error(
 | 
					      const isAzure = accessStore.provider === ServiceProvider.Azure;
 | 
				
			||||||
        "incomplete azure config, please check it in your settings page",
 | 
					
 | 
				
			||||||
      );
 | 
					      if (isAzure && !accessStore.isValidAzure()) {
 | 
				
			||||||
 | 
					        throw Error(
 | 
				
			||||||
 | 
					          "incomplete azure config, please check it in your settings page",
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (isAzure) {
 | 
				
			||||||
 | 
					        path = makeAzurePath(path, accessStore.azureApiVersion);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      baseUrl = isAzure ? accessStore.azureUrl : accessStore.openaiUrl;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let baseUrl = isAzure ? accessStore.azureUrl : accessStore.openaiUrl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (baseUrl.length === 0) {
 | 
					    if (baseUrl.length === 0) {
 | 
				
			||||||
      const isApp = !!getClientConfig()?.isApp;
 | 
					      const isApp = !!getClientConfig()?.isApp;
 | 
				
			||||||
      baseUrl = isApp
 | 
					      baseUrl = isApp
 | 
				
			||||||
@@ -84,10 +92,6 @@ export class ChatGPTApi implements LLMApi {
 | 
				
			|||||||
      baseUrl = "https://" + baseUrl;
 | 
					      baseUrl = "https://" + baseUrl;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (isAzure) {
 | 
					 | 
				
			||||||
      path = makeAzurePath(path, accessStore.azureApiVersion);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    console.log("[Proxy Endpoint] ", baseUrl, path);
 | 
					    console.log("[Proxy Endpoint] ", baseUrl, path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return [baseUrl, path].join("/");
 | 
					    return [baseUrl, path].join("/");
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -63,26 +63,26 @@ export function createWebDavClient(store: SyncStore) {
 | 
				
			|||||||
      };
 | 
					      };
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    path(path: string, proxyUrl: string = "") {
 | 
					    path(path: string, proxyUrl: string = "") {
 | 
				
			||||||
      // if (!path.endsWith("/")) {
 | 
					 | 
				
			||||||
      //   path += "/";
 | 
					 | 
				
			||||||
      // }
 | 
					 | 
				
			||||||
      if (path.startsWith("/")) {
 | 
					      if (path.startsWith("/")) {
 | 
				
			||||||
        path = path.slice(1);
 | 
					        path = path.slice(1);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (proxyUrl.length > 0 && !proxyUrl.endsWith("/")) {
 | 
					      if (proxyUrl.endsWith("/")) {
 | 
				
			||||||
        proxyUrl += "/";
 | 
					        proxyUrl = proxyUrl.slice(0, -1);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let url;
 | 
					      let url;
 | 
				
			||||||
      if (proxyUrl.length > 0) {
 | 
					      const pathPrefix = "/api/webdav/";
 | 
				
			||||||
        let u = new URL(proxyUrl + "api/webdav/" + path);
 | 
					
 | 
				
			||||||
 | 
					      try {
 | 
				
			||||||
 | 
					        let u = new URL(proxyUrl + pathPrefix + path);
 | 
				
			||||||
        // add query params
 | 
					        // add query params
 | 
				
			||||||
        u.searchParams.append("endpoint", config.endpoint);
 | 
					        u.searchParams.append("endpoint", config.endpoint);
 | 
				
			||||||
        url = u.toString();
 | 
					        url = u.toString();
 | 
				
			||||||
      } else {
 | 
					      } catch (e) {
 | 
				
			||||||
        url = "/api/upstash/" + path + "?endpoint=" + config.endpoint;
 | 
					        url = pathPrefix + path + "?endpoint=" + config.endpoint;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      return url;
 | 
					      return url;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user