How to use secret value on morph.io and local?

I’m using node.js on macos but although I reference process.env.MORPH_API_KEY it is only populated on morph.io and is ‘undefined’ on local.

I’m guessing that this is the same issue as reported on Github https://github.com/openaustralia/morph/issues/1187.

Code that you run via morph-cli is completely independent of the scrapers that exist on morph.io. They’re not attached to a particular scraper and so don’t have access to the environment variables that are set.

Also, code that is run via morph-cli is not visible anywhere so there is no harm in embedding secret values in the code. This is perfectly fine for prototyping things. When you’re close to getting things working refactor your code (to pull out the secret values into environment variables) and check it into git.

Hope that helps.

Thanks for the response. I ended up using
var api_key = process.env.MORPH_API_KEY;
in my code to access the secret when running on morph.io, and using
MORPH_API_KEY={api_key} node scraper.js
when running the same code locally.