2
0

🔥 Remove VIEWER_URL_INTERNAL variable

BREAKING CHANGE: NEXT_PUBLIC_VIEWER_INTERNAL does not exist anymore as typebot.io now directly points to the viewer project
This commit is contained in:
Baptiste Arnaud
2023-11-23 15:21:07 +01:00
parent 542e632472
commit 73d2e165bf
22 changed files with 51 additions and 48 deletions

View File

@@ -20,7 +20,6 @@ export const SupportBubble = (props: Omit<BubbleProps, 'typebot'>) => {
return (
<Bubble
apiHost="https://viewer.typebot.io"
typebot="typebot-support"
prefilledVariables={{
'User ID': user?.id,

View File

@@ -1,6 +1,6 @@
import { Variable, WebhookResponse } from '@typebot.io/schemas'
import { sendRequest } from '@typebot.io/lib'
import { getViewerUrl } from '@typebot.io/lib/getViewerUrl'
import { env } from '@typebot.io/env'
export const executeWebhook = (
typebotId: string,
@@ -8,7 +8,7 @@ export const executeWebhook = (
{ blockId }: { blockId: string }
) =>
sendRequest<WebhookResponse>({
url: `${getViewerUrl()}/api/typebots/${typebotId}/blocks/${blockId}/executeWebhook`,
url: `${env.NEXT_PUBLIC_VIEWER_URL[0]}/api/typebots/${typebotId}/blocks/${blockId}/executeWebhook`,
method: 'POST',
body: {
variables,

View File

@@ -18,8 +18,8 @@ import {
Text,
Stack,
} from '@chakra-ui/react'
import { getViewerUrl } from '@typebot.io/lib/getViewerUrl'
import { ModalProps } from '../EmbedButton'
import { env } from '@typebot.io/env'
export const FlutterFlowModal = ({
isPublished,
@@ -51,12 +51,12 @@ export const FlutterFlowModal = ({
<InputGroup size="sm">
<Input
type={'text'}
defaultValue={`${getViewerUrl()}/${publicId}`}
defaultValue={`${env.NEXT_PUBLIC_VIEWER_URL[0]}/${publicId}`}
/>
<InputRightElement width="60px">
<CopyButton
size="sm"
textToCopy={`${getViewerUrl()}/${publicId}`}
textToCopy={`${env.NEXT_PUBLIC_VIEWER_URL[0]}/${publicId}`}
/>
</InputRightElement>
</InputGroup>

View File

@@ -1,9 +1,9 @@
import { FlexProps } from '@chakra-ui/react'
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
import { getViewerUrl } from '@typebot.io/lib/getViewerUrl'
import { CodeEditor } from '@/components/inputs/CodeEditor'
import prettier from 'prettier/standalone'
import parserHtml from 'prettier/parser-html'
import { env } from '@typebot.io/env'
type Props = {
widthLabel: string
@@ -13,7 +13,7 @@ type Props = {
export const IframeSnippet = ({ widthLabel, heightLabel }: Props) => {
const { typebot } = useTypebot()
const src = `${getViewerUrl()}/${typebot?.publicId}`
const src = `${env.NEXT_PUBLIC_VIEWER_URL[0]}/${typebot?.publicId}`
const code = prettier.format(
`<iframe src="${src}" style="border: none; width=${widthLabel}; height=${heightLabel}"></iframe>`,
{ parser: 'html', plugins: [parserHtml] }

View File

@@ -18,8 +18,8 @@ import {
Text,
Stack,
} from '@chakra-ui/react'
import { getViewerUrl } from '@typebot.io/lib/getViewerUrl'
import { ModalProps } from '../EmbedButton'
import { env } from '@typebot.io/env'
export const NotionModal = ({
isPublished,
@@ -49,12 +49,12 @@ export const NotionModal = ({
<InputGroup size="sm">
<Input
type={'text'}
defaultValue={`${getViewerUrl()}/${publicId}`}
defaultValue={`${env.NEXT_PUBLIC_VIEWER_URL[0]}/${publicId}`}
/>
<InputRightElement width="60px">
<CopyButton
size="sm"
textToCopy={`${getViewerUrl()}/${publicId}`}
textToCopy={`${env.NEXT_PUBLIC_VIEWER_URL[0]}/${publicId}`}
/>
</InputRightElement>
</InputGroup>

View File

@@ -41,7 +41,6 @@ import {
} from '@chakra-ui/react'
import { env } from '@typebot.io/env'
import { isEmpty, isNotEmpty } from '@typebot.io/lib/utils'
import { getViewerUrl } from '@typebot.io/lib/getViewerUrl'
import React, { useState } from 'react'
import { createId } from '@paralleldrive/cuid2'
@@ -449,9 +448,7 @@ const Webhook = ({
credentialsId: string
}) => {
const { workspace } = useWorkspace()
const webhookUrl = `${
env.NEXT_PUBLIC_VIEWER_INTERNAL_URL ?? getViewerUrl()
}/api/v1/workspaces/${workspace?.id}/whatsapp/${credentialsId}/webhook`
const webhookUrl = `${env.NEXT_PUBLIC_VIEWER_URL[0]}/api/v1/workspaces/${workspace?.id}/whatsapp/${credentialsId}/webhook`
return (
<Stack spacing={6}>

View File

@@ -12,7 +12,7 @@ import {
import { useState } from 'react'
import { StandardSettings } from '../../../settings/StandardSettings'
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
import { getViewerUrl } from '@typebot.io/lib/getViewerUrl'
import { env } from '@typebot.io/env'
type Props = {
publicId: string
@@ -76,7 +76,7 @@ const parseWordpressShortcode = ({
publicId: string
}) => {
return `[typebot typebot="${publicId}"${
isCloudProdInstance() ? '' : ` host="${getViewerUrl()}"`
isCloudProdInstance() ? '' : ` host="${env.NEXT_PUBLIC_VIEWER_URL[0]}"`
}${width ? ` width="${width}"` : ''}${height ? ` height="${height}"` : ''}]
`
}

View File

@@ -2,10 +2,10 @@ import { BotProps } from '@typebot.io/nextjs'
import parserBabel from 'prettier/parser-babel'
import prettier from 'prettier/standalone'
import { isDefined } from '@typebot.io/lib'
import { getViewerUrl } from '@typebot.io/lib/getViewerUrl'
import { Typebot } from '@typebot.io/schemas'
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
import packageJson from '../../../../../../../../packages/embeds/js/package.json'
import { env } from '@typebot.io/env'
export const parseStringParam = (
fieldName: string,
@@ -59,7 +59,7 @@ export const parseApiHost = (
customDomain: Typebot['customDomain'] | undefined
) => {
if (customDomain) return new URL(`https://${customDomain}`).origin
return getViewerUrl()
return env.NEXT_PUBLIC_VIEWER_URL[0]
}
export const parseApiHostValue = (

View File

@@ -1,11 +1,11 @@
import { Seo } from '@/components/Seo'
import { Flex } from '@chakra-ui/react'
import { Standard } from '@typebot.io/nextjs'
import { getViewerUrl } from '@typebot.io/lib/getViewerUrl'
import { SettingsSideMenu } from './SettingsSideMenu'
import { TypebotHeader } from '@/features/editor/components/TypebotHeader'
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
import { TypebotNotFoundPage } from '@/features/editor/components/TypebotNotFoundPage'
import { env } from '@typebot.io/env'
export const SettingsPage = () => {
const { typebot, is404 } = useTypebot()
@@ -18,7 +18,12 @@ export const SettingsPage = () => {
<Flex h="full" w="full">
<SettingsSideMenu />
<Flex flex="1">
{typebot && <Standard apiHost={getViewerUrl()} typebot={typebot} />}
{typebot && (
<Standard
apiHost={env.NEXT_PUBLIC_VIEWER_URL[0]}
typebot={typebot}
/>
)}
</Flex>
</Flex>
</Flex>