Module 23Neill's Vibe · Tier 1 · Ship-First-App Scars~8 min

The key everyone could read

It was in the page. Right-click, view-source, and there it sat — a paid key anyone could copy and run up your bill.

01 · the scene

The embed snippet carried the key in plain sight.

A partner-facing scan tool shipped each firm's API key inside the page so the browser could call the service. It worked. It also meant the key was sitting in the HTML for anyone to read.

tax-scanner-api — view-source on a partner site — May 21
<!-- right-click > View Source on any partner page -->
<div id="scan" data-api-key="live_key_a1b2c3d4e5">
# copy that key, replay it, and trigger $25 scans on someone else's account.
Neill51% · the terrain

"The page needed the key to do the work, so the key was in the page. That felt normal. I didn't clock that 'in the page' means 'anyone who views source has it.' How is that even a secret then?"

Claude49% · the execution

"It isn't. Anything the browser receives, the user receives — view-source is one click. The key should never have left the server. The fix is to keep it server-side behind a proxy and let the page identify itself only by a public slug. I should've inverted that from the start."

02 · the why

If the browser can see it, so can the user.

The browser is the user's machine. Everything you send it — HTML, inline JavaScript, a data- attribute — is fully visible with one right-click. So a real secret can never live in the page. The safe shape is to keep the secret on a server you control (a small proxy), have the browser call your server with only a public, non-secret slug, and let your server attach the real key out of sight. A leaked client key is worse than it sounds: it can be replayed against your account, and you often can't revoke it without re-architecting the whole integration.

⊙

The browser is theirs

view-source = trivial

Whatever you ship to the page, the visitor already has. There is no hiding inside HTML.

⛨

Server proxy

secret stays put

The key lives on your server. The page calls your server; your server calls the API.

#

Public slug

identifies, doesn't authorize

The page sends a non-secret name. Leaking it does nothing — it grants no power on its own.

The model: handing the browser your API key is like taping your house key to the front door with a note "for deliveries." It does the job — and anyone walking past can copy it. Instead you put a doorman (your server) in front: visitors give their name (the public slug), the doorman holds the only key, and the key never leaves the building.

03 · predict it

The key is in the page and it works. What's the real problem?

A partner's embed needs to call a paid API, so the key is shipped in the page's HTML. It functions perfectly. Where's the danger?

Not it. "It works" and "only partners use it" don't hold — the page is public and view-source is one click. And you can't hide a key by obfuscating it in HTML the browser still has to read. Think about who can see what you send the browser.
Exactly. The browser is the user's machine; whatever you ship to it, they have. A client-side key can be harvested and replayed against your account, and may not even be revocable cleanly. Keep the secret server-side behind a proxy; identify the client with a public slug only.
04 · the walkthrough

Inverting the auth so the key never ships.

key in data-api-key
the trapThe real key rides in the page. View-source, copy, replay. Anyone can bill your account.
page → your /scan proxy
step 1The browser calls a small server endpoint you own — sending only a public slug, no secret.
server attaches the key
step 2Your server holds the real key (in its env) and adds it when it calls the upstream API.
slug leak = harmless
step 3If the public slug leaks, nothing happens — it identifies the client, it doesn't authorize spend.
05 · prove it · gate

Teach it back to unlock the payoff.

Same rule as always: answer it right, or the module isn't done.

Your page needs to call a paid API. Where does the real API key go, and what does the browser send instead?
// one correct answer unlocks Module 23
Not the load-bearing reason. Obfuscation, a private repo, and rotation don't help — the browser still receives the key and view-source still shows it. Think about keeping the secret off the user's machine entirely.
That's it. The browser is the user's machine, so a secret can never live in the page. Put it behind a server proxy and identify the client with a harmless public slug. If the slug leaks, nothing leaks. Module unlocked. ↓
the durable idea

If the browser can read it, it's not a secret. Real keys live server-side; the page carries only a public name that grants no power on its own.

06 · factory payoff
⊘ locked — pass the teach-back to claim this piece of the factory

The proxy pattern that keeps the key off the page.

A real proxy-route.js — a minimal server endpoint that takes a public slug from the browser, looks up the secret key server-side, and forwards the call so the key never reaches the page. Plus a short audit checklist for catching a leaked client-side secret before a partner does.

✓ Module 23 complete