2
0

revert(viewer): ️ Make sure old viewer URL still works

This commit is contained in:
Baptiste Arnaud
2022-03-23 08:53:00 +01:00
parent 03aadab409
commit b16c47adb9

View File

@@ -11,12 +11,11 @@ export const getServerSideProps: GetServerSideProps = async (
let typebot: Omit<PublicTypebot, 'createdAt' | 'updatedAt'> | null let typebot: Omit<PublicTypebot, 'createdAt' | 'updatedAt'> | null
const isIE = /MSIE|Trident/.test(context.req.headers['user-agent'] ?? '') const isIE = /MSIE|Trident/.test(context.req.headers['user-agent'] ?? '')
const pathname = context.resolvedUrl.split('?')[0] const pathname = context.resolvedUrl.split('?')[0]
console.log('pathname:', pathname)
try { try {
if (!context.req.headers.host) return { props: {} } if (!context.req.headers.host) return { props: {} }
console.log('context.req.headers.host:', context.req.headers.host) const viewerUrls = (process.env.NEXT_PUBLIC_VIEWER_URL ?? '').split(',')
typebot = context.req.headers.host.includes( typebot = viewerUrls.some((url) =>
(process.env.NEXT_PUBLIC_VIEWER_URL ?? '').split('//')[1] context.req.headers.host?.includes(url.split('//')[1])
) )
? await getTypebotFromPublicId(context.query.publicId?.toString()) ? await getTypebotFromPublicId(context.query.publicId?.toString())
: await getTypebotFromCustomDomain( : await getTypebotFromCustomDomain(