🔊 Add logs to debug invalid env
This commit is contained in:
@ -1,9 +1,8 @@
|
||||
import { gtmHeadSnippet } from '@/lib/google-tag-manager'
|
||||
import { Metadata } from '@typebot.io/schemas'
|
||||
import Head from 'next/head'
|
||||
import Script from 'next/script'
|
||||
import React from 'react'
|
||||
import { isNotEmpty } from '@typebot.io/lib'
|
||||
import { Metadata } from '@typebot.io/schemas/features/typebot/settings'
|
||||
|
||||
type SEOProps = {
|
||||
url: string
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Standard } from '@typebot.io/nextjs'
|
||||
import { BackgroundType, Typebot } from '@typebot.io/schemas'
|
||||
import { useRouter } from 'next/router'
|
||||
import { SEO } from './Seo'
|
||||
import { Typebot } from '@typebot.io/schemas/features/typebot/typebot'
|
||||
import { BackgroundType } from '@typebot.io/schemas/features/typebot/theme/enums'
|
||||
|
||||
export type TypebotV3PageProps = {
|
||||
url: string
|
||||
|
21
packages/env/env.ts
vendored
21
packages/env/env.ts
vendored
@ -1,7 +1,11 @@
|
||||
import { createEnv } from '@t3-oss/env-nextjs'
|
||||
import { z } from 'zod'
|
||||
import { ZodError, z } from 'zod'
|
||||
import { getRuntimeVariable } from './getRuntimeVariable'
|
||||
|
||||
declare const window: {
|
||||
__ENV?: any
|
||||
}
|
||||
|
||||
const boolean = z.enum(['true', 'false']).transform((value) => value === 'true')
|
||||
|
||||
const baseEnv = {
|
||||
@ -313,6 +317,21 @@ export const env = createEnv({
|
||||
...sentryEnv.runtimeEnv,
|
||||
...posthogEnv.runtimeEnv,
|
||||
},
|
||||
onValidationError: (error: ZodError) => {
|
||||
console.log(
|
||||
'[DEBUG]',
|
||||
"typeof window !== 'undefined'",
|
||||
typeof window !== 'undefined'
|
||||
)
|
||||
if (typeof window !== 'undefined') {
|
||||
console.log('[DEBUG]', 'window.__ENV', window.__ENV)
|
||||
}
|
||||
console.error(
|
||||
'❌ Invalid environment variables:',
|
||||
error.flatten().fieldErrors
|
||||
)
|
||||
throw new Error('Invalid environment variables')
|
||||
},
|
||||
onInvalidAccess: (variable: string) => {
|
||||
throw new Error(
|
||||
`❌ Attempted to access a server-side environment variable on the client: ${variable}`
|
||||
|
Reference in New Issue
Block a user