From 36c01d89c94e3abbaab079179c46ee1521ba5107 Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 29 Oct 2024 15:19:47 +0800 Subject: [PATCH] fix: cros promblem --- web/app/components/plugins/plugin-page/index.tsx | 5 ++--- web/service/base.ts | 4 ++++ web/service/plugins.ts | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/web/app/components/plugins/plugin-page/index.tsx b/web/app/components/plugins/plugin-page/index.tsx index 80492d0c18..80f8f22ade 100644 --- a/web/app/components/plugins/plugin-page/index.tsx +++ b/web/app/components/plugins/plugin-page/index.tsx @@ -74,9 +74,8 @@ const PluginPage = ({ (async () => { await sleep(100) if (packageId) { - const data = await fetchManifestFromMarketPlace(encodeURIComponent(packageId)) - // wait for add cors - setManifest(data) + const { data } = await fetchManifestFromMarketPlace(encodeURIComponent(packageId)) + setManifest(data.plugin) showInstallFromMarketplace() } })() diff --git a/web/service/base.ts b/web/service/base.ts index f90e3ef1b1..8efb97cff3 100644 --- a/web/service/base.ts +++ b/web/service/base.ts @@ -290,11 +290,15 @@ const baseFetch = ( }: IOtherOptions, ): Promise => { const options: typeof baseOptions & FetchOptionType = Object.assign({}, baseOptions, fetchOptions) + if (isMarketplaceAPI) + options.credentials = 'omit' + if (getAbortController) { const abortController = new AbortController() getAbortController(abortController) options.signal = abortController.signal } + if (isPublicAPI) { const sharedToken = globalThis.location.pathname.split('/').slice(-1)[0] const accessToken = localStorage.getItem('token') || JSON.stringify({ [sharedToken]: '' }) diff --git a/web/service/plugins.ts b/web/service/plugins.ts index 05ec73c7b1..6a2cb063fd 100644 --- a/web/service/plugins.ts +++ b/web/service/plugins.ts @@ -80,7 +80,7 @@ export const fetchManifest = async (uniqueIdentifier: string) => { } export const fetchManifestFromMarketPlace = async (uniqueIdentifier: string) => { - return getMarketplace(`/plugins/identifier?unique_identifier=${uniqueIdentifier}`) + return getMarketplace<{ data: { plugin: PluginDeclaration } }>(`/plugins/identifier?unique_identifier=${uniqueIdentifier}`) } export const installPackageFromMarketPlace = async (uniqueIdentifier: string) => {