๐—ฆ๐˜๐—ผ๐—ฝ ๐—Ÿ๐—ฒ๐—ฎ๐—ธ๐—ถ๐—ป๐—ด ๐—ฌ๐—ผ๐˜‚๐—ฟ ๐—”๐—ฃ๐—œ ๐—ž๐—ฒ๐˜†๐˜€

I leaked my API key twice.

First, I put the key in a JavaScript file. I pushed it to GitHub. A scanner found it.

Second, I used an environment variable in React. The key lived in the browser. Anyone with DevTools saw the key.

Client side secrets are not secrets.

I built a proxy. I used Cloudflare Workers.

The process is simple:

The API key never enters the browser.

Benefits:

Production tips:

Keep your keys on the server.

Source: https://dev.to/__c1b9e06dc90a7e0a676b/i-exposed-my-api-key-twice-before-building-a-proxy-heres-what-i-learned-1l28