Skip to content

Commit

Permalink
fix(viewer): 🐛 Make custom domain fetching more predictable
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed May 2, 2022
1 parent 28710dd commit 8fdfda6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions apps/builder/components/share/ShareContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ export const ShareContent = () => {
: ''
const isPublished = isDefined(typebot?.publishedTypebotId)

const handlePathnameChange = (pathname: string) => {
if (!typebot?.customDomain) return
const existingHost = typebot.customDomain?.split('/')[0]
const newDomain =
pathname === '' ? existingHost : existingHost + '/' + pathname
handleCustomDomainChange(newDomain)
}

const handleCustomDomainChange = (customDomain: string | null) =>
updateOnBothTypebots({ customDomain })

Expand All @@ -65,11 +73,7 @@ export const ShareContent = () => {
<EditableUrl
hostname={'https://' + typebot.customDomain.split('/')[0]}
pathname={typebot.customDomain.split('/')[1]}
onPathnameChange={(pathname) =>
handleCustomDomainChange(
typebot.customDomain?.split('/')[0] + '/' + pathname
)
}
onPathnameChange={handlePathnameChange}
/>
<IconButton
icon={<TrashIcon />}
Expand Down
2 changes: 1 addition & 1 deletion apps/viewer/pages/[[...publicId]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const getTypebotFromPublicId = async (publicId?: string) => {

const getTypebotFromCustomDomain = async (customDomain: string) => {
const typebot = await prisma.publicTypebot.findFirst({
where: { customDomain: { contains: customDomain } },
where: { customDomain },
})
if (isNotDefined(typebot)) return null
return omit(typebot as unknown as PublicTypebot, 'createdAt', 'updatedAt')
Expand Down

4 comments on commit 8fdfda6

@vercel
Copy link

@vercel vercel bot commented on 8fdfda6 May 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-typebot-io.vercel.app
builder-v2-git-main-typebot-io.vercel.app
app.typebot.io

@vercel
Copy link

@vercel vercel bot commented on 8fdfda6 May 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 8fdfda6 May 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.