๐—œ ๐—˜๐˜…๐—ฝ๐—ผ๐˜€๐—ฒ๐—ฑ ๐— ๐˜† ๐—”๐—ฃ๐—œ ๐—ž๐—ฒ๐˜† ๐—ง๐˜„๐—ถ๐—ฐ๐—ฒ

I leaked my API key twice while building a side project.

First, I hardcoded the key in a JavaScript file. I pushed it to GitHub. A security scanner caught it. I rotated the key.

Second, I used a .env file. The key still appeared in the browser network tab. Anyone with DevTools saw it.

Client-side secrets are not secrets.

I built a proxy using Cloudflare Workers. Here is how it works:

The API key never touches the browser.

Why this works:

My lessons:

What is your setup? Do you use a proxy or a managed service?

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