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',
|
||||
}}
|
||||
>
|
||||
{!process.env.NEXT_PUBLIC_VIEWER_URL ? (
|
||||
<>
|
||||
<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>
|
||||
)
|
||||
}
|
||||
|
@ -14,12 +14,20 @@ export const getServerSideProps: GetServerSideProps = async (
|
||||
try {
|
||||
if (!context.req.headers.host) return { props: {} }
|
||||
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])
|
||||
)
|
||||
const customDomain = `${context.req.headers.host}${
|
||||
pathname === '/' ? '' : pathname
|
||||
}`
|
||||
typebot = isMatchingViewerUrl
|
||||
? await getTypebotFromPublicId(context.query.publicId?.toString())
|
||||
: await getTypebotFromCustomDomain(
|
||||
`${context.req.headers.host}${pathname === '/' ? '' : pathname}`
|
||||
: await getTypebotFromCustomDomain(customDomain)
|
||||
if (!typebot)
|
||||
console.log(
|
||||
isMatchingViewerUrl
|
||||
? `Couldn't find publicId: ${context.query.publicId?.toString()}`
|
||||
: `Couldn't customDomain: ${customDomain}`
|
||||
)
|
||||
return {
|
||||
props: {
|
||||
|
Reference in New Issue
Block a user