diff --git a/frontend/app/src/env.ts b/frontend/app/src/env.ts index 71f775f77..69795090c 100644 --- a/frontend/app/src/env.ts +++ b/frontend/app/src/env.ts @@ -201,7 +201,7 @@ export const EnvSchema = v.pipe( export type Env = v.InferOutput; -const parsedEnv = v.parse(EnvSchema, { +const parsedEnv = v.safeParse(EnvSchema, { APP_VERSION: process.env.APP_VERSION, // set in next.config.js BLOCKING_LIST: process.env.NEXT_PUBLIC_BLOCKING_LIST, BLOCKING_VPNAPI: process.env.NEXT_PUBLIC_BLOCKING_VPNAPI, @@ -275,6 +275,14 @@ const parsedEnv = v.parse(EnvSchema, { COLL_2_CONTRACT_TROVE_NFT: process.env.NEXT_PUBLIC_COLL_2_CONTRACT_TROVE_NFT, }); +if (!parsedEnv.success) { + console.error( + "Invalid environment variable(s):", + v.flatten(parsedEnv.issues), + ); + throw new Error("Invalid environment variable(s)"); +} + export const { APP_VERSION, BLOCKING_LIST, @@ -306,4 +314,4 @@ export const { DEPLOYMENT_FLAVOR, VERCEL_ANALYTICS, WALLET_CONNECT_PROJECT_ID, -} = parsedEnv; +} = parsedEnv.output;