🔊 Add DEBUG mode with valuable logs in viewer
This commit is contained in:
@ -17,6 +17,7 @@ Parameters marked with <Asterix/> are required.
|
||||
| ENCRYPTION_SECRET <Asterix/> | | 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 <Asterix/> | | The viewer base URL. Should be the publicly accessible URL (i.e. `https://bot.domain.com`) |
|
||||
| NEXTAUTH_URL <Asterix/> | | 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)
|
||||
|
||||
|
@ -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
|
||||
}`
|
||||
|
Reference in New Issue
Block a user