© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Cloudflare DevelopersCD
Cloudflare Developers•16mo ago
agni

next.js worker not finding environment variables

hi!

i have a cloudflare worker that i'm trying to deploy and have environment variables that i'm using.

i've added the environment variables within the env variables within the worker but the build isn't able to find it (i'm using https://github.com/t3-oss/t3-env to manage my env variable validations). would anyone know how i can further debug this issue? if i have a local
.env
.env
file, the build works smoothly and as such believed the worker build environment would read from the environment variables

for more reference, this is how my
env.ts
env.ts
file looks like :

import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";

export const env = createEnv({
    server: {
        NEWS_API_ENDPOINT: z.string().url(),
        NEWS_API_API_KEY: z.string().min(32),
        OPENAI_SECRET_KEY: z.string().min(1),
        OPENAI_ORG_ID: z.string().min(1),
        CHRONICLE_R2_ENDPOINT: z.string().url(),
        CHRONICLE_R2_ACCESS_ID: z.string().min(1),
        CHRONICLE_R2_SECRET_KEY: z.string().min(1),
        CHRONICLE_R2_BUCKET_NAME: z.string().min(1),
    },
    client: {},
    // For Next.js >= 13.4.4, you only need to destructure client variables:
    experimental__runtimeEnv: {},
});
import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";

export const env = createEnv({
    server: {
        NEWS_API_ENDPOINT: z.string().url(),
        NEWS_API_API_KEY: z.string().min(32),
        OPENAI_SECRET_KEY: z.string().min(1),
        OPENAI_ORG_ID: z.string().min(1),
        CHRONICLE_R2_ENDPOINT: z.string().url(),
        CHRONICLE_R2_ACCESS_ID: z.string().min(1),
        CHRONICLE_R2_SECRET_KEY: z.string().min(1),
        CHRONICLE_R2_BUCKET_NAME: z.string().min(1),
    },
    client: {},
    // For Next.js >= 13.4.4, you only need to destructure client variables:
    experimental__runtimeEnv: {},
});


i'm using all the variables on server side and nothing on the client. would love to provide more information - appreciate the help!!
image.png
GitHub
GitHub - t3-oss/t3-env
Contribute to t3-oss/t3-env development by creating an account on GitHub.
GitHub - t3-oss/t3-env
Cloudflare Developers banner
Cloudflare DevelopersJoin
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
85,042Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

CF Worker not getting environment variables
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
4mo ago
worker environment variables, please help :)
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
3y ago
Protect a Next.JS worker
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
10mo ago