Files
web/packages/common/env/server.ts
Anton Gunnarsson e1ede52014 Merged in fix/common-package-fix (pull request #2355)
fix: Tiny fixes in common package

* Fix self-referencing and circular imports

* Fix env isServer


Approved-by: Joakim Jäderberg
2025-06-13 11:36:40 +00:00

30 lines
926 B
TypeScript

import { createEnv } from "@t3-oss/env-nextjs"
import { z } from "zod"
export const env = createEnv({
/**
* Due to t3-env only checking typeof window === "undefined"
* and Netlify running Deno, window is never "undefined"
* https://github.com/t3-oss/t3-env/issues/154
*/
isServer: typeof window === "undefined" || "Deno" in window,
server: {
NODE_ENV: z.enum(["development", "test", "production"]),
REDIS_API_HOST: z.string().optional(),
REDIS_API_KEY: z.string().optional(),
BRANCH:
process.env.NODE_ENV !== "development"
? z.string()
: z.string().optional().default("dev"),
GIT_SHA: z.string().optional(),
},
emptyStringAsUndefined: true,
runtimeEnv: {
NODE_ENV: process.env.NODE_ENV,
REDIS_API_HOST: process.env.REDIS_API_HOST,
REDIS_API_KEY: process.env.REDIS_API_KEY,
BRANCH: process.env.BRANCH,
GIT_SHA: process.env.GIT_SHA,
},
})