Hi guys, I have a problem with my environment variables. I’m currently using a plugin called ‘netlify-plugin-contextual-env’ and it changes the env vars like this: SEND_GRID_KEY becomes STAGING_SEND_GRID_KEY and PRODUCTION_SEND_GRID_KEY accordingly.
Then in my function am using it like this
const sendGridKey = process.env.SEND_GRID_KEY
In my netlify build and deploy settings I have the following keys:
SEND_GRID_KEY
STAGING_SEND_GRID_KEY
PRODUCTION_SEND_GRID_KEY
However, my function always refers to the value of SEND_GRID_KEY
Do I still need a conditional like this:
let sendGridKey;
if (context === "production") {
sendGridKey = process.env.SEND_GRID_KEY
} else if (context === "deploy-preview" || context === "branch-deploy") {
sendGridKey = process.env.STAGING_SEND_GRID_KEY
}
If so, why do we need the plugin in the first place?
Please let me know if where is my error when using the plugin.
Thank you!