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?
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.
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
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.
How does Glitch load .env file? I’m trying to replicate this in my local computer.
Install Node.js and the dotenv package to load .env
It’s already installed. You should remix ~hello-express to get a node app that’s ready to go. Specifically speaking, you need a package.json with a start script. Best to remix another project really.