mirror of
https://github.com/langgenius/dify.git
synced 2026-09-07 18:36:02 +08:00
21 lines
811 B
TypeScript
21 lines
811 B
TypeScript
import { memo } from 'react'
|
|
import { IS_PROD, ZENDESK_WIDGET_KEY } from '@/config'
|
|
import { prefetchSystemFeatures } from '@/features/system-features/server'
|
|
import { headers } from '@/next/headers'
|
|
import { ZendeskScript } from './script'
|
|
|
|
const Zendesk = async () => {
|
|
if (!ZENDESK_WIDGET_KEY) return null
|
|
|
|
const systemFeatures = await prefetchSystemFeatures()
|
|
if (!systemFeatures || systemFeatures.deployment_edition !== 'CLOUD') return null
|
|
|
|
const nonce = IS_PROD ? ((await headers()).get('x-nonce') ?? '') : ''
|
|
/* v8 ignore next -- `nonce` is always a string (`''` or header value), so nullish fallback is unreachable in runtime. @preserve */
|
|
const scriptNonce = nonce ?? undefined
|
|
|
|
return <ZendeskScript nonce={scriptNonce} widgetKey={ZENDESK_WIDGET_KEY} />
|
|
}
|
|
|
|
export default memo(Zendesk)
|