menu

ZEIT

Our mission is to make cloud computing as easy and accessible as mobile computing. You can find our Next.js community here.

Channels
Team

Using .env file to set enviroment varibles with micro and pm2 outside now

January 31, 2019 at 5:35pm
The ZEIT community has a new home. This thread is preserved for historical purposes. The content of this conversation may be innaccurrate or out of date. Go to new community home →

Using .env file to set enviroment varibles with micro and pm2 outside now

January 31, 2019 at 5:35pm
I'm used to use .env files for setting my secret keys and additional config for my different environments, with micro-dev, .env files works fine, but when i try to use same file with micro doest not work. I am missing something?

January 31, 2019 at 6:29pm
Can you give a reproduction code? It should work just fine...
  • reply
  • like
I solved this by adding it to my index file and reviewing the code in micro-dev. They do that in micro-dev/bin/micro-dev.js and in micro donenv it is not a dependency, so im not sure if this is the correct way to do this
  • reply
  • like
  • reply
  • like

February 11, 2019 at 2:36am
, there's a better way. use secrets
  • reply
  • like

January 5, 2020 at 3:02pm
hi im trying to understand how to configure the env here - how to use secrets? can you give me links? whats the best practice for micro framework? can you help? thanks guys
  • reply
  • like

January 5, 2020 at 10:32pm
2 steps: 1) add entries to your now.json like this: "env": {"NAME_OF_VAR": ""}, then 2) at bash: now secret add "name-of-secret" "value-of-secret". now you can pick up the value within your code formprocess.env.NAME_OF_VAR`
  • reply
  • like

February 17, 2020 at 12:03am

February 17, 2020 at 9:08am
Note that this works only when running now dev.
  • reply
  • like
private
This channel has been archived