From 8c96b1170994d5e23638e3871a972ae8448d3ada Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Thu, 14 Mar 2024 02:13:48 +0700 Subject: [PATCH] [Cherry Pick] [Head Repo] fix: auto migrate proxy config (#307) Co-authored-by: fred-bf --- app/store/sync.ts | 13 ++++++++++++- app/utils/cors.ts | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/store/sync.ts b/app/store/sync.ts index 5782f72d548..e7932bf8829 100644 --- a/app/store/sync.ts +++ b/app/store/sync.ts @@ -238,7 +238,8 @@ export const useSyncStore = createPersistStore( }), { name: StoreKey.Sync, - version: 1.2, // golang syncing + version: 1.3, // golang syncing + migrate(persistedState, version) { const newState = persistedState as typeof DEFAULT_SYNC_STATE; if (version < 1.1) { @@ -247,6 +248,16 @@ export const useSyncStore = createPersistStore( if (version < 1.2) { newState.gosync.username = STORAGE_KEY; } + + if (version < 1.3) { + if ( + (persistedState as typeof DEFAULT_SYNC_STATE).proxyUrl === + "/api/cors/" + ) { + newState.proxyUrl = ""; + } + } + return newState as any; }, }, diff --git a/app/utils/cors.ts b/app/utils/cors.ts index 93956a7b5c7..fa348f9bf5d 100644 --- a/app/utils/cors.ts +++ b/app/utils/cors.ts @@ -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; }