Netlify.toml only overwrites variables defined in .env when preceded with NEXT_PUBLIC_

I’m encountering an issue with environment variables in a next.js app. I’m using both .env and netlify.toml files to manage environment variables, but which variable comes through is dependent on whether it begins with NEXT_PUBLIC. For example, if I had a .env with

EXAMPLE="ABC"
NEXT_PUBLIC_EXAMPLE="1"

and a netlify.toml file with

[context.dev.environment]
    EXAMPLE = "DEF"
    NEXT_PUBLIC_EXAMPLE="2"

In the dev environment, process.env.NEXT_PUBLIC_EXAMPLE will be “2”, but process.env.EXAMPLE (which I may use in a server action) will be “ABC.”

When I set it in the Netlify Dashboard it works as I would hope, but I would be interested in what the root of this discrepancy is & I’d prefer to manage the non-secret environment variables in netlify.toml if possible.

Any ideas would be appreciated. Thanks!

We’ve responded to this question in our helpdesk, feel free to follow-up with any questions there!