I’ve read a lot of posts about the use of netlify.toml for environment variables, but what I can’t seem to get a handle on is if I can use the environment variables defined in a netlify.toml within Netlify serverless functions.
For example, I’ve created a netlify.toml file with the as you see below.
[build] command = "npm run build" publish = "public/" functions = "functions" [[plugins]] package = "@netlify/plugin-gatsby" [context.production.environment] MY_VAR = "some value" [context.branch-deploy.environment] MY_VAR = "some other value"
When I deploy this and try to access the MY_VAR variable within the serverless function it shows as undefined. However, I did nearly the same thing only used a Gatsby function and the variable seems to be accessible.
Can anyone steer me in the right direction?