I would like to use different credentials in my functions depending on my NODE_ENV variable. I have a Gatsby project and when I do netlify dev Gatsby sets NODE_ENV === development and gatsby develop command sets it to production (at least this is what I get
when I log NODE_ENV from gatsby-config.js). However it doesn’t seem to apply to my functions.
Please have a look at Auth.js file
Some interesting observations (LMK if they are not related to the current issue and have to be posted in another place). I was following this post about
.env variables in Gatsby project.
It suggests introducing another variable, e.g.
GATSBY_ACTIVE_ENV and set it up manually. I was able to run
GATSBY_ACTIVE_ENV=development netlify dev as expected, though adding
GATSBY_ACTIVE_ENV=development netlify dev command under scripts in
package.json and running
yarn develop was causing an endless loop. After getting in the loop once you are not able to run
GATSBY_ACTIVE_ENV=development netlify dev anymore without getting in the loop.