.env variables failed to load

I want to fill my Railway Postgres database with data which I have locally. I have followed nexxel's create-t3-app tut to create a database added all the env variables but this is happening.
12 Replies
Sean Cassiere
Sean Cassiere•3y ago
It looks like your env variables aren't being picked up (which is weird since the NODE_ENV should be automatically set). If this is a screenshot of your local dev instance, then I'd hate to say it, but it may just be one of those give it a restart scenario. If this an error log, from a deployment to Railway, then you'll need to add your environment variables for your deployment (https://docs.railway.app/develop/variables).
Sean Cassiere
Sean Cassiere•3y ago
In the event, you weren't sure how to get to the panel to add your environment variables on Railway, the screenshots below should help.
aditya
adityaOP•3y ago
it is a local dev instance idk why but whenever i import the fill db function i made it shows this errors
Unknown User
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Christoph
Christoph•3y ago
_app.tsx is run on server and client. NODE_ENV only exists on the server, not in the browser. Don't try to run server-code in the browser.
zenith
zenith•3y ago
@aditya you need to include all environment variables that are defined in your env schema, which includes all of these
zenith
zenith•3y ago
so you need the discord and nextauth as well to get this working now you can mark them optional by adding .optional() to the zod schema
Sean Cassiere
Sean Cassiere•3y ago
Didn't realize that... In your _app.tsx, you can't import the server.mjs since those variables are only available on the server-side. To expose stuff on the client-side you need to prefix it was NEXT_PUBLIC. BUT YOU MUST BE EXTREMELY CAREFUL, when choosing what you are exposing to the client-side since server secrets generally should be private.
zenith
zenith•3y ago
I think we're getting a bit offtopic for aditya can you show us what you mean by this? specifically can we see what you mean by the "fill db function" if the code is open source pls link repo otherwise screenshots are great
aditya
adityaOP•3y ago
I have added all the env variables sure I'll upload to github
aditya
adityaOP•3y ago
GitHub
GitHub - aditya-exe/crwn-clothing-v2
Contribute to aditya-exe/crwn-clothing-v2 development by creating an account on GitHub.
aditya
adityaOP•3y ago
I have not touched anything from create-t3-app initial structure only made the scripts folder and some changes to index.tsx also I tried to use ts-node to run the script didn't work gave some weird errors well it turns out I was doing this. Problem solved👌
Want results from more Discord servers?
Add your server