Gatsby: What's the reason to prefix client-side env vars with GATSBY_

Created on 10 Apr 2020  路  2Comments  路  Source: gatsbyjs/gatsby

Some hours I tried to configure what was happening, after diving in documentations and some research I found that:

In addition to these Project Environment Variables defined in .env.* files, you could also define OS Env Vars. OS Env Vars which are prefixed with GATSBY_ will become available in browser JavaScript.

So my question is why is it necessary to prefix with GATSBY_ and my suggestion is about ability to configure if someone wants to use vars in client side without specific prefix.

question or discussion

All 2 comments

I think React documentation has a great explanation for this practice.

Note: You must create custom environment variables beginning with REACT_APP_. Any other variables except NODE_ENV will be ignored to avoid accidentally exposing a private key on the machine that could have the same name.

I think React documentation has a great explanation for this practice.

Note: You must create custom environment variables beginning with REACT_APP_. Any other variables except NODE_ENV will be ignored to avoid accidentally exposing a private key on the machine that could have the same name.

Great, I didn't know it, that's good answer for my question.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dustinhorton picture dustinhorton  路  3Comments

jimfilippou picture jimfilippou  路  3Comments

timbrandin picture timbrandin  路  3Comments

totsteps picture totsteps  路  3Comments

dustinhorton picture dustinhorton  路  3Comments