Invalid Environment Variables In Brandnew Project

Just ran create-t3-app and just added one environment variable: Inside .env.mjs:
server: {
DATABASE_URL: z.string().url(),
NODE_ENV: z.enum(["development", "test", "production"]),
PAYPAL_SECRET: z.string(),
},
server: {
DATABASE_URL: z.string().url(),
NODE_ENV: z.enum(["development", "test", "production"]),
PAYPAL_SECRET: z.string(),
},
and in my .env:
DATABASE_URL="file:./db.sqlite"
PAYPAL_SECRET="123"
DATABASE_URL="file:./db.sqlite"
PAYPAL_SECRET="123"
However, I get:
❌ Invalid environment variables: { PAYPAL_SECRET: [ 'Required' ] } - error Failed to load next.config.mjs, see more info here https://nextjs.org/docs/messages/next-config-error Error: Invalid environment variables
What am I missing here?
Solution:
you need to add your new env var to runtimeEnv in env.mjs
Jump to solution
2 Replies
Solution
Matvey
Matvey2y ago
you need to add your new env var to runtimeEnv in env.mjs
plyglt
plyglt2y ago
ohhhhh thanks a lot yes, forgot the destructuring!!
Want results from more Discord servers?
Add your server