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