🩹 (share) Fix undefined apiHost under API instructions
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import prettier from 'prettier/standalone'
|
||||
import parserHtml from 'prettier/parser-html'
|
||||
import {
|
||||
parseApiHost,
|
||||
parseApiHostValue,
|
||||
parseInitBubbleCode,
|
||||
typebotImportCode,
|
||||
} from '../../snippetParsers'
|
||||
@@ -19,7 +19,7 @@ export const JavascriptBubbleSnippet = ({ theme, previewMessage }: Props) => {
|
||||
|
||||
${parseInitBubbleCode({
|
||||
typebot: typebot?.publicId ?? '',
|
||||
apiHost: parseApiHost(typebot?.customDomain),
|
||||
apiHost: parseApiHostValue(typebot?.customDomain),
|
||||
theme: {
|
||||
...theme,
|
||||
chatWindow: {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
||||
import parserHtml from 'prettier/parser-html'
|
||||
import prettier from 'prettier/standalone'
|
||||
import {
|
||||
parseApiHost,
|
||||
parseApiHostValue,
|
||||
parseInitPopupCode,
|
||||
typebotImportCode,
|
||||
} from '../../snippetParsers'
|
||||
@@ -16,7 +16,7 @@ export const JavascriptPopupSnippet = ({ autoShowDelay }: Props) => {
|
||||
const snippet = prettier.format(
|
||||
createSnippet({
|
||||
typebot: typebot?.publicId ?? '',
|
||||
apiHost: parseApiHost(typebot?.customDomain),
|
||||
apiHost: parseApiHostValue(typebot?.customDomain),
|
||||
autoShowDelay,
|
||||
}),
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import parserHtml from 'prettier/parser-html'
|
||||
import prettier from 'prettier/standalone'
|
||||
import {
|
||||
parseApiHost,
|
||||
parseApiHostValue,
|
||||
parseInitStandardCode,
|
||||
typebotImportCode,
|
||||
} from '../../snippetParsers'
|
||||
@@ -40,7 +40,7 @@ export const parseStandardHeadCode = (
|
||||
|
||||
${parseInitStandardCode({
|
||||
typebot: publicId ?? '',
|
||||
apiHost: parseApiHost(customDomain),
|
||||
apiHost: parseApiHostValue(customDomain),
|
||||
})}</script>`,
|
||||
{ parser: 'html', plugins: [parserHtml] }
|
||||
)
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
parseInlineScript,
|
||||
parseInitBubbleCode,
|
||||
typebotImportCode,
|
||||
parseApiHost,
|
||||
parseApiHostValue,
|
||||
} from '../../../snippetParsers'
|
||||
|
||||
export const parseDefaultBubbleTheme = (typebot?: Typebot) => ({
|
||||
@@ -36,7 +36,7 @@ export const ScriptBubbleInstructions = () => {
|
||||
|
||||
${parseInitBubbleCode({
|
||||
typebot: typebot?.publicId ?? '',
|
||||
apiHost: parseApiHost(typebot?.customDomain),
|
||||
apiHost: parseApiHostValue(typebot?.customDomain),
|
||||
theme,
|
||||
previewMessage,
|
||||
})}`
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useState } from 'react'
|
||||
import { PopupSettings } from '../../../settings/PopupSettings'
|
||||
import { parseInitPopupCode } from '../../../snippetParsers'
|
||||
import {
|
||||
parseApiHost,
|
||||
parseApiHostValue,
|
||||
parseInlineScript,
|
||||
typebotImportCode,
|
||||
} from '../../../snippetParsers/shared'
|
||||
@@ -19,7 +19,7 @@ export const ScriptPopupInstructions = () => {
|
||||
|
||||
${parseInitPopupCode({
|
||||
typebot: typebot?.publicId ?? '',
|
||||
apiHost: parseApiHost(typebot?.customDomain),
|
||||
apiHost: parseApiHostValue(typebot?.customDomain),
|
||||
autoShowDelay: inputValue,
|
||||
})}`
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@ import { StandardSettings } from '../../../settings/StandardSettings'
|
||||
import { parseInitStandardCode } from '../../../snippetParsers/standard'
|
||||
import { parseStandardElementCode } from '../../Javascript/JavascriptStandardSnippet'
|
||||
import {
|
||||
parseApiHost,
|
||||
parseApiHostValue,
|
||||
parseInlineScript,
|
||||
typebotImportCode,
|
||||
} from '../../../snippetParsers/shared'
|
||||
@@ -30,7 +30,7 @@ export const ScriptStandardInstructions = () => {
|
||||
|
||||
${parseInitStandardCode({
|
||||
typebot: typebot?.publicId ?? '',
|
||||
apiHost: parseApiHost(typebot?.customDomain),
|
||||
apiHost: parseApiHostValue(typebot?.customDomain),
|
||||
})}`)
|
||||
|
||||
return (
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
import { BubbleProps } from '@typebot.io/js'
|
||||
import { useState } from 'react'
|
||||
import { BubbleSettings } from '../../../settings/BubbleSettings/BubbleSettings'
|
||||
import { parseApiHost, parseInitBubbleCode } from '../../../snippetParsers'
|
||||
import { parseApiHostValue, parseInitBubbleCode } from '../../../snippetParsers'
|
||||
import { parseDefaultBubbleTheme } from '../../Javascript/instructions/JavascriptBubbleInstructions'
|
||||
|
||||
type Props = {
|
||||
@@ -29,7 +29,7 @@ export const WordpressBubbleInstructions = ({ publicId }: Props) => {
|
||||
|
||||
const initCode = parseInitBubbleCode({
|
||||
typebot: publicId,
|
||||
apiHost: parseApiHost(typebot?.customDomain),
|
||||
apiHost: parseApiHostValue(typebot?.customDomain),
|
||||
theme: {
|
||||
...theme,
|
||||
chatWindow: {
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
import { useState } from 'react'
|
||||
import { PopupSettings } from '../../../settings/PopupSettings'
|
||||
import { parseInitPopupCode } from '../../../snippetParsers/popup'
|
||||
import { parseApiHost } from '../../../snippetParsers'
|
||||
import { parseApiHostValue } from '../../../snippetParsers'
|
||||
|
||||
type Props = {
|
||||
publicId: string
|
||||
@@ -25,7 +25,7 @@ export const WordpressPopupInstructions = ({
|
||||
|
||||
const initCode = parseInitPopupCode({
|
||||
typebot: publicId,
|
||||
apiHost: parseApiHost(customDomain),
|
||||
apiHost: parseApiHostValue(customDomain),
|
||||
autoShowDelay,
|
||||
})
|
||||
|
||||
|
||||
@@ -51,7 +51,12 @@ export const parseApiHost = (
|
||||
customDomain: Typebot['customDomain'] | undefined
|
||||
) => {
|
||||
if (customDomain) return new URL(`https://${customDomain}`).origin
|
||||
return isCloudProdInstance
|
||||
? undefined
|
||||
: env('VIEWER_INTERNAL_URL') ?? getViewerUrl()
|
||||
return env('VIEWER_INTERNAL_URL') ?? getViewerUrl()
|
||||
}
|
||||
|
||||
export const parseApiHostValue = (
|
||||
customDomain: Typebot['customDomain'] | undefined
|
||||
) => {
|
||||
if (isCloudProdInstance) return
|
||||
return parseApiHost(customDomain)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user