I'm trying to use an environment variable in my serverMiddleware in Nuxt.js. It works fine when it starts with a letter (MY_SECRET
) but since it's a private server variable I'd like it to start with an underscore (_MY_SECRET
). However for some reason the latter is undefined.
This is my basic setup:
// .env
MY_SECRET = hello
_MY_SECRET = world
// serverMiddleware/index.js
console.log(process.env.MY_SECRET, process.env._MY_SECRET) // output: hello undefined
Why does this happen and what other options do I have to prefix my private variables?