Netlify mapped js website doesnt run when deployed and runs when yarn started

Hey! I have a react app, that is working when i run command yarn start and doesn’t after i upload build folder to netlify (I get an error “uncaught ReferenceError: $______$exports is not defined”) after i run start the build folder the website works but my secret stuff in .env get exposed. Any solutions?

Hey @TurtleMoon

Anything in a React (or other client-side) app is visible to the user. So if you have

const seviceAPIKey = process.env.SECRET_API_KEY

the value of this secret is visible. Better to use Netlify Functions as outlined in [Support Guide] How do I keep my API keys/tokens safe using Netlify Functions? Also check out [Support Guide] Using environment variables on Netlify correctly.