@ -5,6 +5,7 @@ import { Typebot } from '@typebot.io/schemas/features/typebot/typebot'
|
||||
import { BackgroundType } from '@typebot.io/schemas/features/typebot/theme/constants'
|
||||
import { defaultSettings } from '@typebot.io/schemas/features/typebot/settings/constants'
|
||||
import { Font } from '@typebot.io/schemas'
|
||||
import { useMemo } from 'react'
|
||||
|
||||
export type TypebotV3PageProps = {
|
||||
url: string
|
||||
@ -40,6 +41,8 @@ export const TypebotPageV3 = ({
|
||||
push(asPath.split('?')[0], undefined, { shallow: true })
|
||||
}
|
||||
|
||||
const apiOrigin = useMemo(() => new URL(url).origin, [url])
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
@ -58,6 +61,7 @@ export const TypebotPageV3 = ({
|
||||
typebot={publicId}
|
||||
onInit={clearQueryParamsIfNecessary}
|
||||
font={font ?? undefined}
|
||||
apiHost={apiOrigin}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
@ -45,6 +45,13 @@ export const getServerSideProps: GetServerSideProps = async (
|
||||
const { host, forwardedHost } = getHost(context.req)
|
||||
log(`host: ${host}`)
|
||||
log(`forwardedHost: ${forwardedHost}`)
|
||||
const protocol =
|
||||
context.req.headers['x-forwarded-proto'] === 'https' ||
|
||||
(context.req.socket as unknown as { encrypted: boolean }).encrypted
|
||||
? 'https'
|
||||
: 'http'
|
||||
|
||||
log(`Request protocol: ${protocol}`)
|
||||
try {
|
||||
if (!host) return { props: {} }
|
||||
const viewerUrls = env.NEXT_PUBLIC_VIEWER_URL
|
||||
@ -71,7 +78,7 @@ export const getServerSideProps: GetServerSideProps = async (
|
||||
props: {
|
||||
publishedTypebot,
|
||||
incompatibleBrowser,
|
||||
url: `https://${forwardedHost ?? host}${pathname}`,
|
||||
url: `${protocol}://${forwardedHost ?? host}${pathname}`,
|
||||
},
|
||||
}
|
||||
} catch (err) {
|
||||
@ -80,7 +87,7 @@ export const getServerSideProps: GetServerSideProps = async (
|
||||
return {
|
||||
props: {
|
||||
incompatibleBrowser,
|
||||
url: `https://${forwardedHost ?? host}${pathname}`,
|
||||
url: `${protocol}://${forwardedHost ?? host}${pathname}`,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user