Problems with environment variables

Hi @hillary

thanks for the answer, let me answer your two suggestions.

About the first thread, yes I already read it before posting. According to Gatsby documentation variables GATSBY_xxx are used to be accessed by the browser as exposed here:

This is not what I want, my vars are only needed in build time to change the endpoints being accessed.

To your second point. Just to clarify, I do not need these variables to be accessed by any functions, just Gatsby Build process. I have tested both approaches having .env files and setting them up in the toml file.

No success.

As I want the variables to have different values for production and staging (branch deployment) using the UI is not a valid option, my reasoning:

  • UI does not allow me to have different values per different deployment type, they are all shared.
  • Then, I would need to use different VAR names, like. PROD_VAR, STAGING_VAR
  • Having different VAR names is forcing me to detect in build time in what type of deployment the build is being run to use one or the other
  • and then I am back to my original problem…

Gatsby is not reading the variables setup neither in .env.staging, neither in TOML file.

I am sure this is some mis-configuration on my side, or not clearly understanding something in Gatsby, but I am blocked with this right now.

I will make some more tests today and try to bring logs and examples with TOML file defined variables.

Thx.