Skip to content

Commit

Permalink
Merge pull request ChatGPTNextWeb#4288 from fred-bf/fix/migrate-proxy…
Browse files Browse the repository at this point in the history
…-url

fix: auto migrate proxy config
  • Loading branch information
fred-bf committed Mar 13, 2024
2 parents 7c04a90 + 066ca9e commit cc0eae7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/store/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
},
},
Expand Down
3 changes: 3 additions & 0 deletions app/utils/cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit cc0eae7

Please sign in to comment.