Env variable in Galaxy Dashboard : undefined

Hello,

I cannot access the env variable I have set in Galaxy dashboard. Someone please tell me why?

I set it up in the dashboard, then try to access it with

  const testEnvVar = process.env.TEST_ENV_VAR;
  console.log("Value of TEST_ENV_VAR:", testEnvVar);

I returns undefined.

(I cannot use a settings.json file as there are private keys I can’t push to github.) What am I missing?

many thanks

Hi Sugoke, I replied to the email you sent to our support. I believe it went into your spam folder. I responded as follows:

The configuration of environment variables via push to deploy will not be visible inside the container, they only exist during the build and deployment of the app. A useful use for them is to specify the region where the application will be deployed or the memory limit.

To use environment variables that work within your application, you need to create the settings.json file in the application directory or edit it in Galaxy:


I recommend reading this documentation: Deployment configurations | Galaxy Docs

Printing example, remember to use the --settings flag when deploying:

Meteor.startup(() => {
// code to run on server at startup
console.log(Meteor.settings["galaxy.meteor.com"].env.TEST_ENV_VAR)
});

Regards,
Thiago Reis.