{"success":true,"name":"the-frontend-bundle-is-public-never-hide-secrets-or-logic-in","description":"Tempted to put a key, check, or hidden feature only in frontend code","category":"ai-brimind","path":"ai-brimind/the-frontend-bundle-is-public-never-hide-secrets-or-logic-in/SKILL.md","file":"SKILL.md","content":"---\nname: the-frontend-bundle-is-public-never-hide-secrets-or-logic-in\ndescription: \"Tempted to put a key, check, or hidden feature only in frontend code\"\n---\n\n# The Frontend Bundle Is Public: Never Hide Secrets or Logic in Client Code\n\n## When to use\nYou are placing something sensitive in client-side code — a key, a role check, unreleased features, pricing logic — assuming users won't find it.\n\n## Example request\nA 'hidden' admin route only unlinked in the menu → the route name ships in the JavaScript bundle where anyone can read it; the server must protect it (bundles are readable). Discount calculation done in the browser → users edit the number before it is sent; price logic and final math belong server-side (client math is a suggestion). Unreleased feature code shipped behind a frontend flag → competitors and users read the bundle and find it; unfinished features stay out of shipped code or behind server gates (feature exposure). A private API key in a React component 'just for now' → build tools inline it into files everyone downloads; server-side proxying is the pattern (key exposure).\n\n## Instructions\nAct like a developer who has opened the browser's dev tools on their own app and read the bundle the way a stranger would — because every user downloads your entire frontend source, prettified or not. Before placing anything in client code, classify it: is this a secret (key, token), a decision (permission, price, limit), or a disclosure (hidden routes, unreleased features, internal endpoints)? Secrets never ship to the client — calls needing private keys go through your own server endpoint that holds the key. Decisions made in the browser are suggestions: the server recomputes prices, re-checks roles, and re-validates limits, while the frontend version exists only for user experience. Disclosures are inevitable: assume every string in the bundle — route names, API paths, flag names — is public documentation of your system, and make sure knowing them grants nothing without server-side checks. When using build-time environment variables, learn your framework's rule for which ones are embedded into the client bundle and audit what actually ships. Only proceed once nothing in the client code would matter if posted publicly — because it effectively is — and explain how moving secrets and decisions server-side keeps curious users at the glass instead of behind the counter.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #581\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}