Home
Support Forums

Environment Variables not working on deploy preview

The environment variables do not work in the test environment generated in the deploy preview on github. When im on localhost ou production, it works fine.

Could you share a repo or some more information that might help us debug this?

The project is private atm, so i can’t share it… Is there any information that can i give you without be the rep?

Hi @lubomfim,

We would need to see a reproducible case to test this and see what might be happening. Any site ID you could let us know that might be having this issue?

This is the production: https://emprendeoboticario.com.co/
This is the test site: https://deploy-preview-31--portal-inicios-homolog.netlify.app/

Hi @lubomfim,

Could you check if the sensitive variable policy is blocking out the variable in the deploy preview? You could check this by trying to log the variable in your build log by echo $ENV_NAME.

how can i do that, please? @hrishikesh

As I said, you could try to log the variable in your build log, for example if your build command is npm run build, change it to echo $ENV_NAME && npm run build. If the environment variable’s value is printed in the build log, it means it’s usable and should work.

it’s only printing the variable name, not the value.

Hi @lubomfim,

Could we see the deploy log where this has been done? It should not print the name in any case, is what I would think.