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
Please don't send the values but can you duplicate the .env, remove the values so only leaving:
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/introductionEnv
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.
After that I would just check the basics like: you've included your .env in the root folder
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
You probably missed configure your env on aws it's my guess cause i have a compagny app running on it and no issue.
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
Interesting, maybe report it on the github as an issue?
i would thing is i can't provide code examples as they part of the company where i work xD
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
I remember that after settings env variable on amplify I needed to redeploy to have access to them
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