diff --git a/apps/docs/docs/self-hosting/configuration/viewer.mdx b/apps/docs/docs/self-hosting/configuration/viewer.mdx
index 1a83b322e..82982553a 100644
--- a/apps/docs/docs/self-hosting/configuration/viewer.mdx
+++ b/apps/docs/docs/self-hosting/configuration/viewer.mdx
@@ -17,6 +17,7 @@ Parameters marked with are required.
| ENCRYPTION_SECRET | | A 256-bit key used to encrypt sensitive data. It is strongly recommended to [generate](https://www.allkeysgenerator.com/Random/Security-Encryption-Key-Generator.aspx) a new one. The secret should be the same between builder and viewer. |
| NEXT_PUBLIC_VIEWER_URL | | The viewer base URL. Should be the publicly accessible URL (i.e. `https://bot.domain.com`) |
| NEXTAUTH_URL | | The builder base URL. Should be the publicly accessible URL (i.e. `https://typebot.domain.com`) |
+| DEBUG | false | If enabled, the server will print valuable logs to debug config issues. |
## Emails (Notifications)
diff --git a/apps/viewer/src/pages/[[...publicId]].tsx b/apps/viewer/src/pages/[[...publicId]].tsx
index 91af45016..be1fefd46 100644
--- a/apps/viewer/src/pages/[[...publicId]].tsx
+++ b/apps/viewer/src/pages/[[...publicId]].tsx
@@ -29,6 +29,11 @@ const incompatibleBrowsers = [
},
]
+const log = (message: string) => {
+ if (process.env.DEBUG !== 'true') return
+ console.log(`[DEBUG] ${message}`)
+}
+
export const getServerSideProps: GetServerSideProps = async (
context: GetServerSidePropsContext
) => {
@@ -38,9 +43,12 @@ export const getServerSideProps: GetServerSideProps = async (
)?.name ?? null
const pathname = context.resolvedUrl.split('?')[0]
const { host, forwardedHost } = getHost(context.req)
+ log(`host: ${host}`)
+ log(`forwardedHost: ${forwardedHost}`)
try {
if (!host) return { props: {} }
const viewerUrls = (getViewerUrl({ returnAll: true }) ?? '').split(',')
+ log(`viewerUrls: ${viewerUrls}`)
const isMatchingViewerUrl =
env('E2E_TEST') === 'true'
? true
@@ -52,6 +60,7 @@ export const getServerSideProps: GetServerSideProps = async (
.split(':')[0]
.includes(url.split('//')[1].split(':')[0]))
)
+ log(`isMatchingViewerUrl: ${isMatchingViewerUrl}`)
const customDomain = `${forwardedHost ?? host}${
pathname === '/' ? '' : pathname
}`