0

I am using Vue-CLI and trying to hide certain "secrets" from the client-side code using environment variables.

Why do I get an undefined in console?

Root file: .env.development

NODE_ENV=development
SECRET_WORD=foo

app file: src/components/example.vue

export default {
  created() {
    console.log(process.env.SECRET_WORD)
  },
...snip...

Now, if I do VUE_APP_SECRET_WORD=foo with process.env.VUE_APP_SECRET_WORD it works, but I don't want to display secrets statically like that.

redshift
  • 4,815
  • 13
  • 75
  • 138
  • I think this was answered [here](https://stackoverflow.com/questions/50828904/using-environment-variables-with-vue-js) – men32z Jun 26 '19 at 17:35
  • yes but the answer there seems to say that it will transmit secrets to client side code. – redshift Jun 26 '19 at 17:43
  • Update: OK, I understand now. I need to go to my server's settings and input the secrets there...and THEN I can reference the process.env secrets from the client side code. – redshift Jun 26 '19 at 17:46

0 Answers0