Deployment error with working environment variable

I'm trying to deploy on vercel and i got this error below. I can call the OpenAI API (via server side/ api folder). And I've already filled up the env.mjs file. I did not edit the next.config.mjs as the t3 docs did not say anything about editing it. I've tried searching online and can't find any resource on it. (Fyi, my stack is t3 without trpc and nextauth. Also, I'm using pages router.) Do let me know if you need any more information. Below is my error: ❌ Invalid environment variables: { OPENAI_API_KEY: [ 'Required' ] } - error Failed to load next.config.mjs, see more info here https://nextjs.org/docs/messages/next-config-error
Build error occurred
Error: Invalid environment variables at f (file:///vercel/path0/node_modules/@t3-oss/env-nextjs/dist/index.mjs:1:505) at l (file:///vercel/path0/node_modules/@t3-oss/env-nextjs/dist/index.mjs:1:695) at C (file:///vercel/path0/node_modules/@t3-oss/env-nextjs/dist/index.mjs:1:868) at file:///vercel/path0/src/env.mjs:4:20 at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
2 Replies
Luc Ledo
Luc Ledo2y ago
had this problem before, had something to do with not having "NEXT_PUBLIC" on a client side env variable or setting env variable in wrong place either client or server.
dvd545
dvd545OP2y ago
omg. changing the environment variable in vercel site worked. i forgot i moved the env from client side to server side. i'm such a noob. thank you so much for helping.
Want results from more Discord servers?
Add your server