2
0

🐛 Improve parse runtime env reading function

This commit is contained in:
Baptiste Arnaud
2023-08-28 14:19:40 +02:00
parent efd4600b7e
commit 036b407a11
8 changed files with 22 additions and 20 deletions

10
packages/env/env.ts vendored
View File

@ -1,14 +1,6 @@
import { createEnv } from '@t3-oss/env-nextjs'
import { z } from 'zod'
declare const window: {
__ENV: any
}
const getRuntimeVariable = (key: string) => {
if (typeof window === 'undefined') return process.env[key]
return window.__ENV[key]
}
import { getRuntimeVariable } from './getRuntimeVariable'
const boolean = z.enum(['true', 'false']).transform((value) => value === 'true')