Environment Variables questions

@Teodor What will happen if I’m already using environment variables via environment.env in target folder? Will Wappler recognize those or should I re-do this in “Wappler way”?

Looks amazing! :star_struck:
Are the env variables also configurable on the SSL/SSH input fields?
Haven’t upgraded yet. :sweat_smile:

Also, setting custom values, like JSON, in ENV file directly will not mess the Environment tab I hope?

Looks like you can with SSH inputs, but not SSL.

And just on your last question, unless I’m missing something or not understanding correctly, It doesn’t use a .env file, instead, the variables are saved in \app\config\config.json and \.wappler\targets\[Target]\app\config\config.json. I can’t speak for if setting custom values messes up the environment tab, as I haven’t tested that yet.

That would be really weird. Is that correct @Teodor?

That’s what I thought, maybe I’m just looking in the wrong place :smile: but I couldn’t find a .env file in the project. There’s a "env": { } section in said file which has the variables and gets updated when you update them in the UI, and that seems to be the place they are getting pulled from after some quick testing.

I haven’t downloaded it yet… but I think this config is supposed to be a duplicate set of values to be used in DB Connection and other places, where Wappler UI needs to access the values directly, and not from the app server. .env will still have to be created. Just a theory.

That’s also what I assumed, but if I set my database host variable to something random in the config.json directly, the site won’t be able to connect to the database any longer, so it definitely looks like that’s where the site itself is pulling from and not just the Wappler UI. I’ve double-checked, but there are no results for a .env file in my project after setting these up.

You guy are cracking me up haha. I like where this is going.

@Teodor While you were splitting the topic, you could also answer the questions here.
Can you please explain how this environment setup works?

1 Like

@George there are several questions from the community in this topic regarding new feature. It would be great if you could comment them. Thank you in advance.

The values are indeed being placed in the config.json file, Wappler is keeping track of a config.json file per target, so you can set different variables per target.

The config.json has the lowest priority, so see them as default values. The .env and server environment variables will overrule any variables set in the config.json.

1 Like

It would be useful to get the path to the config.json files you are referencing as I have several files in different places and don’t want to edit the wrong one when setting the ENV vars per production & dev targets.
Thank you

@Teodor @George @patrick
How can I configure and manage environment variables for Remote servers created within Wappler? Eg: Digitalocean.

Confusion sets in…

When I use global env vars as mentioned above, they are published to git visible in the /app/config.json file.

When I look for what I would expect would be a .env in /modules it is not there.

It seems like such a simple question… but I have been attempting to resolve for over an hour now, and I guess it’s just my style to raise my hand.

Thanks so much!
~Elle

For anyone else that was confused by this simple concern:

env vars can safely be removed from the config.json once they are added in global settings.

I guess I spoke too soon.

When env var removed from config.json they stop working.

This seems so simply; yet here I am hours later… stuck.