AWS Amplify & T3 stack env var issue

I’m small app with for now only auth and is not detecting env vars on amplify I created with next auth, tailwind and nothing else. On the logs I only see that the next auth and provider env vars are not detected with the message that they are required
10 Replies
Luke
Luke4mo ago
Please don't send the values but can you duplicate the .env, remove the values so only leaving:
ABC=
NEXT_PUBLIC_ABC=
ABC=
NEXT_PUBLIC_ABC=
and so on, and if you're still having issues after all the following can you send those here: if you're trying to access an enviornment variable on the frontend, then you should prefix it with NEXT_PUBLIC_: https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#bundling-environment-variables-for-the-browser Where as for server actions it can be without that prefix. https://env.t3.gg/docs/introduction
Env
Never build your apps with invalid environment variables again. Validate and transform your environment with the full power of Zod.
Configuring: Environment Variables | Next.js
Learn to add and access environment variables in your Next.js application.
Luke
Luke4mo ago
After that I would just check the basics like: you've included your .env in the root folder
Casal0x
Casal0xOP4mo ago
in local the .env works perfectly, but with AWS Amplify is the issue, the env vars are setted for all env, and for one specific one just for testing and they are not being readed by the next also they are just for next auth i don't have any other variable used on client or server components
Steven-sensei
Steven-sensei4mo ago
You probably missed configure your env on aws it's my guess cause i have a compagny app running on it and no issue.
Casal0x
Casal0xOP4mo ago
i think is an issue from t3/env, i removed it just for test and it works perfectly, but it wasn't working with it in amplify
Luke
Luke4mo ago
Interesting, maybe report it on the github as an issue?
Casal0x
Casal0xOP4mo ago
i would thing is i can't provide code examples as they part of the company where i work xD
Luke
Luke4mo ago
Classic haha, is there anything at all you could do to help replicate it? I mean a Next.js amplify config doesn't seem like it would be proprietary and it's in your companies advantage to have it fixed
Steven-sensei
Steven-sensei4mo ago
I remember that after settings env variable on amplify I needed to redeploy to have access to them
Casal0x
Casal0xOP4mo ago
there are a lot of work arround finally i made them work on build time in next.config.js, using {env: all env vars} also in the yml i had to echo all of them
Want results from more Discord servers?
Add your server