build(viewer): 🔊 Better log when can't find a typebot
This commit is contained in:
@ -11,8 +11,25 @@ export const ErrorPage = ({ error }: { error: Error }) => {
|
|||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<h1 style={{ fontWeight: 'bold', fontSize: '30px' }}>{error.name}</h1>
|
{!process.env.NEXT_PUBLIC_VIEWER_URL ? (
|
||||||
<h2>{error.message}</h2>
|
<>
|
||||||
|
<h1 style={{ fontWeight: 'bold', fontSize: '30px' }}>
|
||||||
|
NEXT_PUBLIC_VIEWER_URL is missing
|
||||||
|
</h1>
|
||||||
|
<h2>
|
||||||
|
Make sure to configure the viewer properly (
|
||||||
|
<a href="https://docs.typebot.io/self-hosting/configuration#viewer">
|
||||||
|
https://docs.typebot.io/self-hosting/configuration#viewer
|
||||||
|
</a>
|
||||||
|
)
|
||||||
|
</h2>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<h1 style={{ fontWeight: 'bold', fontSize: '30px' }}>{error.name}</h1>
|
||||||
|
<h2>{error.message}</h2>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,21 @@ export const getServerSideProps: GetServerSideProps = async (
|
|||||||
try {
|
try {
|
||||||
if (!context.req.headers.host) return { props: {} }
|
if (!context.req.headers.host) return { props: {} }
|
||||||
const viewerUrls = (process.env.NEXT_PUBLIC_VIEWER_URL ?? '').split(',')
|
const viewerUrls = (process.env.NEXT_PUBLIC_VIEWER_URL ?? '').split(',')
|
||||||
typebot = viewerUrls.some((url) =>
|
const isMatchingViewerUrl = viewerUrls.some((url) =>
|
||||||
context.req.headers.host?.includes(url.split('//')[1])
|
context.req.headers.host?.includes(url.split('//')[1])
|
||||||
)
|
)
|
||||||
|
const customDomain = `${context.req.headers.host}${
|
||||||
|
pathname === '/' ? '' : pathname
|
||||||
|
}`
|
||||||
|
typebot = isMatchingViewerUrl
|
||||||
? await getTypebotFromPublicId(context.query.publicId?.toString())
|
? await getTypebotFromPublicId(context.query.publicId?.toString())
|
||||||
: await getTypebotFromCustomDomain(
|
: await getTypebotFromCustomDomain(customDomain)
|
||||||
`${context.req.headers.host}${pathname === '/' ? '' : pathname}`
|
if (!typebot)
|
||||||
)
|
console.log(
|
||||||
|
isMatchingViewerUrl
|
||||||
|
? `Couldn't find publicId: ${context.query.publicId?.toString()}`
|
||||||
|
: `Couldn't customDomain: ${customDomain}`
|
||||||
|
)
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
typebot,
|
typebot,
|
||||||
|
Reference in New Issue
Block a user