t3-oss / t3-env

https://env.t3.gg
MIT License
2.45k stars 79 forks source link

Next 14.2.1 support #218

Closed davimarcilio closed 2 months ago

davimarcilio commented 2 months ago

It's not working in the new version of next 14.2.2, I had to downgrade to version 14.1.0 to be able to use it

image

juliusmarminge commented 2 months ago

Failed to reproduce, please reopen with reproduction:

![Uploading CleanShot 2024-04-22 at 10.02.21@2x.png…]()

durdenx commented 2 months ago

The application fails when a required environment variable is set to an empty value, for example:

NEXT_PUBLIC_MY_PUBLIC_KEY=

This issue arises with the current Zod schema validation in env.ts:

NEXT_PUBLIC_MY_PUBLIC_KEY: z.string()

To resolve this, update the schema to allow optional values:

z.string().optional()

It was working before nextjs v14.2

juliusmarminge commented 2 months ago

We have our emptyStringAsUndefined option - maybe Next decided to do something similar, idk

davimarcilio commented 2 months ago

In my case, everything was working when the version was lower than 14.2, after updating it stopped working, I did several tests to try to solve it but the only solution was to return the version