import { createEnv } from "@t3-oss/env-nextjs"; import { z } from "zod"; export const env = createEnv({ /** * Specify your server-side environment variables schema here. This way you can ensure the app * isn't built with invalid env vars. */ server: { NODE_ENV: z .enum(["development", "test", "production"]) .default("development"), APP_DATA_PATH: z.string().optional().default("./config"), APP_PATH: z.string().optional().default("."), AUTH_SECRET: z.string().optional(), AUTH_PASSWORD: z.string().optional(), }, /** * Specify your client-side environment variables schema here. This way you can ensure the app * isn't built with invalid env vars. To expose them to the client, prefix them with * `NEXT_PUBLIC_`. */ client: { NEXT_PUBLIC_APP_SIZE: z.enum(["default", "slim"]).default("default"), }, /** * You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g. * middlewares) or client-side so we need to destruct manually. */ runtimeEnv: { NODE_ENV: process.env.NODE_ENV, AUTH_SECRET: process.env.AUTH_SECRET, AUTH_PASSWORD: process.env.AUTH_PASSWORD, APP_DATA_PATH: process.env.APP_DATA_PATH, APP_PATH: process.env.APP_PATH, NEXT_PUBLIC_APP_SIZE: process.env.NEXT_PUBLIC_APP_SIZE, }, /** * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially * useful for Docker builds. */ skipValidation: !!process.env.SKIP_ENV_VALIDATION, /** * Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and * `SOME_VAR=''` will throw an error. */ emptyStringAsUndefined: true, });