1import { createEnv } from "@t3-oss/env-nextjs";
2import { z } from "zod";
3
4export const env = createEnv({
5 /**
6 * Specify your server-side environment variables schema here. This way you can ensure the app
7 * isn't built with invalid env vars.
8 */
9 server: {
10 DATABASE_URL: z.string().url(),
11 GMAIL_EMAIL: z.string(),
12 GMAIL_PASSWORD: z.string(),
13 NODE_ENV: z
14 .enum(["development", "test", "production"])
15 .default("development"),
16 },
17
18 /**
19 * Specify your client-side environment variables schema here. This way you can ensure the app
20 * isn't built with invalid env vars. To expose them to the client, prefix them with
21 * `NEXT_PUBLIC_`.
22 */
23 client: {
24 // NEXT_PUBLIC_CLIENTVAR: z.string(),
25 NEXT_PUBLIC_WS_URL: z.string(),
26 },
27
28 /**
29 * You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
30 * middlewares) or client-side so we need to destruct manually.
31 */
32 runtimeEnv: {
33 DATABASE_URL: process.env.DATABASE_URL,
34 NODE_ENV: process.env.NODE_ENV,
35 GMAIL_PASSWORD: process.env.GMAIL_PASSWORD,
36 GMAIL_EMAIL: process.env.GMAIL_EMAIL,
37 NEXT_PUBLIC_WS_URL: process.env.NEXT_PUBLIC_WS_URL,
38 // NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
39 },
40 /**
41 * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
42 * useful for Docker builds.
43 */
44 skipValidation: !!process.env.SKIP_ENV_VALIDATION,
45 /**
46 * Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and
47 * `SOME_VAR=''` will throw an error.
48 */
49 emptyStringAsUndefined: true,
50});