I can't access netlify environments

I’m using netlify-cli to deploy my build, and this is my netlify.toml:

[build]
command = "npm run build"
publish = "dist"

[dev]
publish = "dist"

[[headers]]
  for = "*.js" # js files should be set this way
  [headers.values]
    Cache-Control = "public, max-age=604800"
[[headers]]
  for = "*.css" # css files too
  [headers.values]
    Cache-Control = "public, max-age=604800"

In App.js

const test = process.env.REACT_APP_API_URL;
console.log(test);

Test returns undefined.

Am i doing something wrong? I can’t link site for security reasons.

hey, just to be sure: the file needs to be called netlify.toml not netlify.tolm can you confirm the file name is correct before we start debugging?

Just a spelling mistake on my part, the file is called: “netlify.toml”

Hi Henrik,

If you’re using the CLI to deploy, we don’t build your site - you do, locally. Environment variables set anywhere except on your local computer should have no effect on your local run.

But, we also don’t run “App.js” for you at browse time, unless you’re using a function: https://docs.netlify.com/functions/overview/ - so I am a bit confused as to how that test would “run” - if you run it locally, I’d guess you need to set that variable locally :slight_smile:

This post might help clear things up?