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