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);
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: Functions overview | Netlify Docs - 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