feat: Add APP_VERSION to headers for marketplace API requests

This commit is contained in:
WTW0313
2025-09-04 18:01:33 +08:00
committed by twwu
parent a061215e42
commit 4ea8fddf1a
3 changed files with 17 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import type {
PluginsSearchParams,
} from '@/app/components/plugins/marketplace/types'
import {
APP_VERSION,
MARKETPLACE_API_PREFIX,
} from '@/config'
import { getMarketplaceUrl } from '@/utils/var'
@ -49,11 +50,15 @@ export const getMarketplacePluginsByCollectionId = async (collectionId: string,
try {
const url = `${MARKETPLACE_API_PREFIX}/collections/${collectionId}/plugins`
const headers = new Headers({
'X-Dify-Version': APP_VERSION,
})
const marketplaceCollectionPluginsData = await globalThis.fetch(
url,
{
cache: 'no-store',
method: 'POST',
headers,
body: JSON.stringify({
category: query?.category,
exclude: query?.exclude,
@ -83,7 +88,10 @@ export const getMarketplaceCollectionsAndPlugins = async (query?: CollectionsAnd
marketplaceUrl += `&condition=${query.condition}`
if (query?.type)
marketplaceUrl += `&type=${query.type}`
const marketplaceCollectionsData = await globalThis.fetch(marketplaceUrl, { cache: 'no-store' })
const headers = new Headers({
'X-Dify-Version': APP_VERSION,
})
const marketplaceCollectionsData = await globalThis.fetch(marketplaceUrl, { headers, cache: 'no-store' })
const marketplaceCollectionsDataJson = await marketplaceCollectionsData.json()
marketplaceCollections = marketplaceCollectionsDataJson.data.collections
await Promise.all(marketplaceCollections.map(async (collection: MarketplaceCollection) => {