a year ago
My MONGODBURI key is in .env file. if i set this key in railway variables i cant access this through process.env.MONGODBURI.
i don't want to push my (if i push .env to my project then its work) .env in GitHub repo . i want to access my key via railway variables but its not working , i don't know why. ðŸ˜
41 Replies
Normally you use OS and dotenv
then do
from dotenv import load_dotenv
import os
load_dotenv()
pgdatabaseurl = os.getenv("DATABASE_URL")
For example ^
(This is obviously python)
while deploying my project variable that i set in railway is undefine why. (should i hard code my key or should i push my .env file only these tow way is working and this is not ideal thing to do)



Really, to keep it safe, i would recommend putting your key in a .env
May i ask what coding language you are using?
a year ago
in their original screenshot you can see the variable is highlighted in blue(?), that means they have not deployed the changes yet
a year ago
no blue(?) highlight
a year ago
do you see a "Deploy changes" button in a floating popup in your screen?
a year ago
Deploy *
i have been redeploying it again and again , and done all the troubleshooting but my project is not accessing the variable from railway. railway not injecting the variable.
a year ago
ah purple
Also just as a reference you can private your github repo, as railway deploys from privates
i was learning how to set variable without pushing .env in my repo
Just make sure you dont have the variables in plaintext in the script if you are hardcoding it
that is the point (i have set key only in railway variable and accessing it via process.env) its not hard coadded nor i have pushed my .env its safe(little bit) now
a year ago
smooth, locally only I hope?
it was the button that i have not pushed (deploy) every thing was fine. i was redeploying it again and again. <:kekw:788259314607325204> 😆

Its all good! Now you have learnt <:poggers:720701334659268700>
took me some time as well
Variables stored in railway’s environment variable section, not in github
a year ago
!s
Status changed to Solved brody • 12 months ago
