I have set some environment variables in the Netlify UI.
See here:
I am trying to use them in my code like this:
console.log("AUTH0_DOMAIN:");
console.log(process.env.AUTH0_DOMAIN);
console.log("AUTH0_CLIENT_ID:");
console.log(process.env.AUTH0_CLIENT_ID);
console.log("AUTH0_AUDIENCE:");
console.log(process.env.AUTH0_AUDIENCE);
When starting up the CLI local dev server using ntl dev
it looks like the environment variables are injected:
But they all come through as undefined
as shown here in the console:
So what am I doing wrong?
Why are they coming through as undefined?
P.S. I know I should not be using secret keys here because they will be exposed, but I still want to know how to do it for non-secret stuff.
UPDATE: The environment variables are also undefined after deploying live to Netlify. So it's broken on the live version and dev version.
UPDATE 2: Assigning it to a variable, as per below, also doesn't work:
const a_d = process.env.AUTH0_DOMAIN;
console.log(a_d); // This prints undefined