Struggling to add client-side environment variables
I am trying to add a client-side env variable to my env.mjs...
I added it to the .env file, like so:
FOO_URL=https://example.com/
Then I went to env.mjs and added it to client
object like so:
client: {
NEXT_PUBLIC_FOO_URL: z.string().min(1),
},
and also to the runtimeEnv
object like so:
runtimeEnv: {
NEXT_PUBLIC_FOO_URL: process.env.FOO_URL,
}
,
When running the app I get: Unhandled Runtime Error Error: Invalid environment variables
What am I missing?Solution:Jump to solution
I fixed it...
I changed the
runtimeEnv
object to the following:
` runtimeEnv: {...1 Reply
Solution
I fixed it...
I changed the
runtimeEnv
object to the following:
runtimeEnv: {
NEXT_PUBLIC_FOO_URL: process.env.NEXT_PUBLIC_FOO_URL,
},
Wasn't obvious to me tbh