mirror of
				https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
				synced 2025-11-04 16:23:41 +08:00 
			
		
		
		
	fix: auto migrate proxy config
This commit is contained in:
		@@ -118,7 +118,7 @@ export const useSyncStore = createPersistStore(
 | 
			
		||||
  }),
 | 
			
		||||
  {
 | 
			
		||||
    name: StoreKey.Sync,
 | 
			
		||||
    version: 1.1,
 | 
			
		||||
    version: 1.2,
 | 
			
		||||
 | 
			
		||||
    migrate(persistedState, version) {
 | 
			
		||||
      const newState = persistedState as typeof DEFAULT_SYNC_STATE;
 | 
			
		||||
@@ -127,6 +127,15 @@ export const useSyncStore = createPersistStore(
 | 
			
		||||
        newState.upstash.username = STORAGE_KEY;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (version < 1.2) {
 | 
			
		||||
        if (
 | 
			
		||||
          (persistedState as typeof DEFAULT_SYNC_STATE).proxyUrl ===
 | 
			
		||||
          "/api/cors/"
 | 
			
		||||
        ) {
 | 
			
		||||
          newState.proxyUrl = "";
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      return newState as any;
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,9 @@ import { ApiPath, DEFAULT_API_HOST } from "../constant";
 | 
			
		||||
export function corsPath(path: string) {
 | 
			
		||||
  const baseUrl = getClientConfig()?.isApp ? `${DEFAULT_API_HOST}` : "";
 | 
			
		||||
 | 
			
		||||
  if (baseUrl === "" && path === "") {
 | 
			
		||||
    return "";
 | 
			
		||||
  }
 | 
			
		||||
  if (!path.startsWith("/")) {
 | 
			
		||||
    path = "/" + path;
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user