diff --git a/apps/builder/components/share/EditableUrl.tsx b/apps/builder/components/share/EditableUrl.tsx
index 9ccc17a39..24e040d92 100644
--- a/apps/builder/components/share/EditableUrl.tsx
+++ b/apps/builder/components/share/EditableUrl.tsx
@@ -30,7 +30,7 @@ export const EditableUrl = ({
onSubmit={onPublicIdChange}
>
- https://
+ {process.env.NEXT_PUBLIC_VIEWER_HOST}/
-
-
- .typebot.io/
-
+
)
diff --git a/apps/builder/services/publicTypebot.tsx b/apps/builder/services/publicTypebot.tsx
index 5faf1473d..b88d8c023 100644
--- a/apps/builder/services/publicTypebot.tsx
+++ b/apps/builder/services/publicTypebot.tsx
@@ -4,7 +4,6 @@ import {
PublicBlock,
PublicStep,
PublicTypebot,
- Step,
Typebot,
} from 'models'
import shortId from 'short-uuid'
@@ -17,10 +16,15 @@ import { isDefined } from '@udecode/plate-common'
export const parseTypebotToPublicTypebot = (
typebot: Typebot
): PublicTypebot => ({
- ...typebot,
id: shortId.generate(),
typebotId: typebot.id,
blocks: parseBlocksToPublicBlocks(typebot.blocks),
+ edges: typebot.edges,
+ name: typebot.name,
+ publicId: typebot.publicId,
+ settings: typebot.settings,
+ theme: typebot.theme,
+ variables: typebot.variables,
})
const parseBlocksToPublicBlocks = (blocks: Block[]): PublicBlock[] =>
diff --git a/apps/landing-page/.env.local.example b/apps/landing-page/.env.local.example
new file mode 100644
index 000000000..ea039c293
--- /dev/null
+++ b/apps/landing-page/.env.local.example
@@ -0,0 +1,4 @@
+NOTION_API_TOKEN=
+NOTION_DATABASE_ID=
+NEXT_PUBLIC_VIEWER_HOST=http://localhost:3001
+LANDING_PAGE_HOST=http://localhost:3002
\ No newline at end of file
diff --git a/apps/landing-page/next.config.js b/apps/landing-page/next.config.js
index 534e71f9b..872a09615 100644
--- a/apps/landing-page/next.config.js
+++ b/apps/landing-page/next.config.js
@@ -10,6 +10,16 @@ const securityHeaders = [
},
]
+const pages = [
+ 'blog',
+ 'pricing',
+ 'privacy-policies',
+ 'terms-of-service',
+ 'vs-landbot',
+ 'vs-tally',
+ 'vs-typeform',
+]
+
module.exports = withBundleAnalyzer({
async headers() {
return [
@@ -30,11 +40,31 @@ module.exports = withBundleAnalyzer({
]
},
async rewrites() {
- return [
- {
- source: '/:path*',
- destination: `${process.env.NEXT_PUBLIC_VIEWER_HOST}/:path*`,
- },
- ]
+ return {
+ beforeFiles: [
+ {
+ source: '/_next/static/:static*',
+ destination:
+ process.env.NEXT_PUBLIC_VIEWER_HOST + '/_next/static/:static*',
+ has: [
+ {
+ type: 'header',
+ key: 'referer',
+ value:
+ process.env.LANDING_PAGE_HOST +
+ '/(?!' +
+ pages.join('|') +
+ '|\\?).+',
+ },
+ ],
+ },
+ ],
+ fallback: [
+ {
+ source: '/:user*',
+ destination: process.env.NEXT_PUBLIC_VIEWER_HOST + '/:user*',
+ },
+ ],
+ }
},
})
diff --git a/apps/landing-page/pages/vs-landbot.tsx b/apps/landing-page/pages/vs-landbot.tsx
index 19e97de3e..e67fddd09 100644
--- a/apps/landing-page/pages/vs-landbot.tsx
+++ b/apps/landing-page/pages/vs-landbot.tsx
@@ -15,13 +15,14 @@ import {
} from '@chakra-ui/react'
import loadLandbot from '../lib/landbot'
import Image from 'next/image'
-import Typebot from 'typebot-js'
+import { initContainer } from 'typebot-js'
import { ArticleCallToAction } from 'components/common/ArticleCta'
import { Footer } from 'components/common/Footer'
import { Navbar } from 'components/common/Navbar/Navbar'
import { NextChakraLink } from 'components/common/nextChakraAdapters/NextChakraLink'
import { SocialMetaTags } from 'components/common/SocialMetaTags'
import { Yes, No } from 'components/common/TableCells'
+import landbotVisualFlowSrc from 'public/images/landbot/visual-flow.png'
// eslint-disable-next-line @typescript-eslint/no-explicit-any
declare const Landbot: any
@@ -35,7 +36,7 @@ const VsTypebot = () => {
'https://chats.landbot.io/v3/H-937813-ZLZEY720UH1TWN5S/index.json',
})
})
- Typebot.initContainer('typebot-container', {
+ initContainer('typebot-container', {
publishId: 'example-vs-other-tools',
})
}, [])
@@ -91,7 +92,7 @@ const VsTypebot = () => {
{
useEffect(() => {
- Typebot.initContainer('typebot-container', {
+ initContainer('typebot-container', {
publishId: 'example-vs-other-tools',
})
}, [])
diff --git a/apps/landing-page/pages/vs-typeform.tsx b/apps/landing-page/pages/vs-typeform.tsx
index 949ebb492..8388cce12 100644
--- a/apps/landing-page/pages/vs-typeform.tsx
+++ b/apps/landing-page/pages/vs-typeform.tsx
@@ -12,7 +12,7 @@ import {
Th,
Flex,
} from '@chakra-ui/react'
-import Typebot from 'typebot-js'
+import { initContainer } from 'typebot-js'
import { CheckIcon } from 'assets/icons/CheckIcon'
import { CloseIcon } from 'assets/icons/CloseIcon'
import { ArticleCallToAction } from 'components/common/ArticleCta'
@@ -25,7 +25,7 @@ import loadTypeform from 'lib/typeform'
const VsTypebot = () => {
useEffect(() => {
loadTypeform().then()
- Typebot.initContainer('typebot-container', {
+ initContainer('typebot-container', {
publishId: 'example-vs-other-tools',
})
}, [])
diff --git a/apps/viewer/pages/[publicId].tsx b/apps/viewer/pages/[publicId].tsx
index 9991ade9c..46a7892c6 100644
--- a/apps/viewer/pages/[publicId].tsx
+++ b/apps/viewer/pages/[publicId].tsx
@@ -7,7 +7,7 @@ import prisma from '../libs/prisma'
export const getServerSideProps: GetServerSideProps = async (
context: GetServerSidePropsContext
) => {
- let typebot: PublicTypebot | undefined
+ let typebot: PublicTypebot | null
const isIE = /MSIE|Trident/.test(context.req.headers['user-agent'] ?? '')
const pathname = context.resolvedUrl.split('?')[0]
try {
@@ -33,12 +33,12 @@ export const getServerSideProps: GetServerSideProps = async (
const getTypebotFromPublicId = async (
publicId?: string
-): Promise => {
- if (!publicId) return
+): Promise => {
+ if (!publicId) return null
const typebot = await prisma.publicTypebot.findUnique({
where: { publicId },
})
- return (typebot as unknown as PublicTypebot | undefined) ?? undefined
+ return (typebot as unknown as PublicTypebot) ?? null
}
const App = ({ typebot, ...props }: TypebotPageProps) =>
diff --git a/apps/viewer/pages/index.tsx b/apps/viewer/pages/index.tsx
deleted file mode 100644
index 02f1d68fd..000000000
--- a/apps/viewer/pages/index.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-import { NotFoundPage } from 'layouts/NotFoundPage'
-import { PublicTypebot } from 'models'
-import { GetServerSideProps, GetServerSidePropsContext } from 'next'
-import { TypebotPage, TypebotPageProps } from '../layouts/TypebotPage'
-import prisma from '../libs/prisma'
-
-export const getServerSideProps: GetServerSideProps = async (
- context: GetServerSidePropsContext
-) => {
- let typebot: PublicTypebot | undefined
- const isIE = /MSIE|Trident/.test(context.req.headers['user-agent'] ?? '')
- const pathname = context.resolvedUrl.split('?')[0]
- try {
- if (!context.req.headers.host) return { props: {} }
- typebot = await getTypebotFromUrl(context.req.headers.host)
- return {
- props: {
- typebot,
- isIE,
- url: `https://${context.req.headers.host}${pathname}`,
- },
- }
- } catch (err) {
- console.error(err)
- }
- return {
- props: {
- isIE,
- url: `https://${context.req.headers.host}${pathname}`,
- },
- }
-}
-
-const getTypebotFromUrl = async (
- hostname: string
-): Promise => {
- const publicId = hostname.split('.').shift()
- if (!publicId) return
- const typebot = await prisma.publicTypebot.findUnique({
- where: { publicId },
- })
- return (typebot as unknown as PublicTypebot | undefined) ?? undefined
-}
-
-const App = ({ typebot, ...props }: TypebotPageProps) =>
- typebot ? :
-export default App
diff --git a/package.json b/package.json
index 3e5603df1..851852a31 100644
--- a/package.json
+++ b/package.json
@@ -16,7 +16,7 @@
},
"devDependencies": {
"dotenv-cli": "^4.1.1",
- "turbo": "^1.1.1"
+ "turbo": "^1.1.2"
},
"packageManager": "yarn@1.22.17"
}
diff --git a/yarn.lock b/yarn.lock
index ceefe433a..2329a2034 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -8073,7 +8073,7 @@ turbo-windows-64@1.1.2:
resolved "https://registry.yarnpkg.com/turbo-windows-64/-/turbo-windows-64-1.1.2.tgz#8eb3f77ab7e04b077752ae2204114c82e5c74697"
integrity sha512-0Ncx/iKhnKrdAU8hJ+8NUcF9jtFr8KoW5mMWfiFzy+mgUbVKbpzWT2eoGR6zJExedQsRvYOejbEX5iihbnj5bA==
-turbo@^1.1.1:
+turbo@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/turbo/-/turbo-1.1.2.tgz#751b9651dc3ebe469898db76afab6405666ad0ff"
integrity sha512-3ViHKyAkaBKNKwHASTa1zkVT3tVVhQNLrpxBS7LoN+794ouQUYmy6lf0rTqzG3iTZHtIDwC+piZSdTl4XjEVMg==