.env file location

RESOLVED Hi, I'm deploying a simple API project and cannot figure out where railway is storing the .env file. I added the variable using the production interface, variables tab, raw editor, ENV. Any help would be greatly appreciated. Thanks!
9 Replies
0xmanny
0xmannyOP3y ago
Solved, by appending echo "$VAR_NAME" > .env to build command
Faraz
Faraz3y ago
You shouldn't need the .env file. We automatically pipe your variables in. Once you add your variable on your service, it should be available to it.
Ricky U
Ricky U3y ago
how would i use the vars in my node app? ${var_name}?
Faraz
Faraz3y ago
Like you would in any other node app. process.env.VAR_NAME_GOES_HERE.
Ricky U
Ricky U3y ago
ah great, so i can use it in dev mode as well as in production. i thought i saw something like ${{varname}} somewhre in the docs
Faraz
Faraz3y ago
You can use it in dev mode if you're using our CLI and starting your server with railway run CMD That's for template variables inside our dashboard. https://docs.railway.app/develop/variables#templated-variables
Ricky U
Ricky U3y ago
yes, i would like to access the template vars in the dashbaord within my app.
Faraz
Faraz3y ago
Within your app. . We just pipe the variables in. Using them within your app works the same way it would irrespective of where you run your app.
Ricky U
Ricky U3y ago
ok thanks it works. well. awesome.
Want results from more Discord servers?
Add your server