How do I set environment variables?


#1

How do I set environment variables? I don’t see the setting for it anywhere. And would other users who visit my project see my keys?


#2

You set them inside your .env file, for example:

HELLO='world'

Then you can use them in your code like this:

process.env.HELLO

And no, if someone views your code without being invited to edit it, they will not see the content of your environment variables, just their names. And if they remix your project, similarly, the values will be blank.


#3

I did exactly what you suggested.

script.js:11 Uncaught ReferenceError: process is not defined
    at script.js:11

and it did not work. Please help at https://glitch.com/edit/#!/nasamix?path=script.js:12:0


#4

You can’t use it on the client-side, it’s server-side only, and you wouldn’t want to because then your secrets will show up in your visitors’ browsers for all to see.