Explicitly add variables and values to .env file


#1

I want to add some values to .env in my project during runtime. Is there any code to do this?


#2

You can set them like you would any variable e.g. process.env.VAR='value'. Note though that it’s just temporary - the values are forgotten or reset to what’s in .env when your project restarts.


#3

Is there a way to store them permanently?


#4

The file system is persistent, so either save the values to a local file or in a database. There are plenty of options with worked example code here: https://glitch.com/storage