mirror of https://github.com/langgenius/dify.git
feat(marketplace): introduce IS_MARKETPLACE flag and update X-Dify-Version header logic
This commit is contained in:
parent
7df6d9f1aa
commit
79c70d09c9
|
|
@ -8,6 +8,7 @@ import type {
|
|||
} from '@/app/components/plugins/marketplace/types'
|
||||
import {
|
||||
APP_VERSION,
|
||||
IS_MARKETPLACE,
|
||||
MARKETPLACE_API_PREFIX,
|
||||
} from '@/config'
|
||||
import { getMarketplaceUrl } from '@/utils/var'
|
||||
|
|
@ -51,7 +52,7 @@ export const getMarketplacePluginsByCollectionId = async (collectionId: string,
|
|||
try {
|
||||
const url = `${MARKETPLACE_API_PREFIX}/collections/${collectionId}/plugins`
|
||||
const headers = new Headers({
|
||||
'X-Dify-Version': APP_VERSION,
|
||||
'X-Dify-Version': !IS_MARKETPLACE ? APP_VERSION : '999.0.0',
|
||||
})
|
||||
const marketplaceCollectionPluginsData = await globalThis.fetch(
|
||||
url,
|
||||
|
|
@ -89,7 +90,7 @@ export const getMarketplaceCollectionsAndPlugins = async (query?: CollectionsAnd
|
|||
if (query?.type)
|
||||
marketplaceUrl += `&type=${query.type}`
|
||||
const headers = new Headers({
|
||||
'X-Dify-Version': APP_VERSION,
|
||||
'X-Dify-Version': !IS_MARKETPLACE ? APP_VERSION : '999.0.0',
|
||||
})
|
||||
const marketplaceCollectionsData = await globalThis.fetch(marketplaceUrl, { headers, cache: 'no-store' })
|
||||
const marketplaceCollectionsDataJson = await marketplaceCollectionsData.json()
|
||||
|
|
|
|||
|
|
@ -421,6 +421,8 @@ export const ZENDESK_FIELD_IDS = {
|
|||
}
|
||||
export const APP_VERSION = pkg.version
|
||||
|
||||
export const IS_MARKETPLACE = globalThis.document?.body?.getAttribute('data-is-marketplace') === 'true'
|
||||
|
||||
export const RAG_PIPELINE_PREVIEW_CHUNK_NUM = 20
|
||||
|
||||
export const PROVIDER_WITH_PRESET_TONE = ['langgenius/openai/openai', 'langgenius/azure_openai/azure_openai']
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import type { AfterResponseHook, BeforeErrorHook, BeforeRequestHook, Hooks } fro
|
|||
import ky from 'ky'
|
||||
import type { IOtherOptions } from './base'
|
||||
import Toast from '@/app/components/base/toast'
|
||||
import { API_PREFIX, APP_VERSION, CSRF_COOKIE_NAME, CSRF_HEADER_NAME, MARKETPLACE_API_PREFIX, PASSPORT_HEADER_NAME, PUBLIC_API_PREFIX, WEB_APP_SHARE_CODE_HEADER_NAME } from '@/config'
|
||||
import { API_PREFIX, APP_VERSION, CSRF_COOKIE_NAME, CSRF_HEADER_NAME, IS_MARKETPLACE, MARKETPLACE_API_PREFIX, PASSPORT_HEADER_NAME, PUBLIC_API_PREFIX, WEB_APP_SHARE_CODE_HEADER_NAME } from '@/config'
|
||||
import Cookies from 'js-cookie'
|
||||
import { getWebAppAccessToken, getWebAppPassport } from './webapp-auth'
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ async function base<T>(url: string, options: FetchOptionType = {}, otherOptions:
|
|||
|
||||
// ! For Marketplace API, help to filter tags added in new version
|
||||
if (isMarketplaceAPI)
|
||||
(headers as any).set('X-Dify-Version', APP_VERSION)
|
||||
(headers as any).set('X-Dify-Version', !IS_MARKETPLACE ? APP_VERSION : '999.0.0')
|
||||
|
||||
const client = baseClient.extend({
|
||||
hooks: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue