Why is adding ENV not amending client side site settings

AI-generated summary

The discussion revolves around why custom environment variables added in app.yml are not appearing as site settings in the client-side application. neounix initially expected that defining an environment variable like DISCOURSE_MY_ENV_TEST in app.yml would automatically make it available as a site setting, based on a previous example involving DISCOURSE_NOTIFICATION_EMAIL. However, sam clarifies that environment variables are not automatically converted into site settings. Instead, a plugin must be created to define a new site setting, which can then be configured via the app.yml file. neounix confirms understanding, and sam reiterates that new site settings require a plugin to be defined.

Hi @sam,

Maybe I am reading this wrong or doing this wrong?

In app.yml , I added a custom env var:

env:
   DISCOURSE_MY_ENV_TEST:  app

and rebuilt the container with a little custom plugin where I dumped all the site settings like this:

console.log(Discourse.SiteSettings);

and it nicely dumps all the site settings to the console as expected; but the custom env: var I set in app.yml do not seem to make it to site settings, as I expected.

Am I doing this wrong?

The reason I ask was I found this topic, searching and looking for a simple way to get env vars into the application so I can use in my plugin; and thought you may be saying that we can do this as described by adding them to the app.yml file; but it’s not working as expected.

PS: Sorry for resurrecting this old topic, but it seemed the closest match based on searching the site and I thought maybe replying here might be better than starting a new topic.

You need to define a plugin with the site setting for this to work. We don’t just pass stuff blindly from ENV to the client.

Hi Sam,

Got it, I think:

So basically we cannot define a new env: variable in the yml file and have that env: var consumed by the site settings in the app unless we create a plugin for this purpose (to add an additional environmental variable for the site, configurable from the yml file).

Is that the correct understanding on my side?

Thanks!

Yeah if you want a new site setting defined it must be added to a plugin.