React .env file security risk: exposing secret keys

🚨 Storing secret keys in React's .env file? You're exposed. REACT_APP_STRIPE_SECRET_KEY=sk_live_abc123 Looks safe. It's not. React runs in the browser. When you run npm run build, your .env variables get bundled into the JavaScript files. Anyone can hit F12 and read your secret key in plain text. The fix is simple 👇 Never call third-party APIs directly from React. Call your own backend instead — and let the backend handle the secret keys. .env in React is fine for public URLs, feature flags, and app environment. Not for secrets. Simple rule → if you'd be embarrassed for anyone to see it, it doesn't belong in React. Have you ever made this mistake? 👇 #ReactJS #JavaScript #WebDevelopment #Security #Frontend

  • text

To view or add a comment, sign in

Explore content categories