source maps
Your production source maps are public: how vibe coders accidentally ship their private code
What .map files are, why Lovable/Bolt/v0/Vite apps leave them on, a two-minute check, and exact Next.js, Vite, and Vercel fixes—then re-scan with the free grader.
Paste your production URL into the free Vibe Code Health grader for a Semrush-style score on secrets, headers, TLS, and common leaks—then come back to this guide for the fixes.
If you shipped a Lovable, Bolt, v0, Replit, or Cursor app this month, open your production URL, append .js.map to a bundled script path (or look for //# sourceMappingURL= at the bottom of a .js file), and you may find something surprising: your original TypeScript/React source, sitting on the public internet.
That file is a source map. It is wonderful when you are debugging. It is a quiet leak when you leave it on for every stranger who can hit “View Source.”
This guide is for beginners. No jargon-first security lecture—just what a source map is, why vibe-coded apps ship them by accident, how to check yours in two minutes, and the exact config flips for Next.js/v0, Vite/Bolt-style stacks, and Vercel.
When you are done, grade your live URL with the free Vibe Code Health scanner. It already flags public maps (including maps that embed full sourcesContent). Pair that with the Learn & FAQ page if any finding codes look unfamiliar.
What a source map actually is
Minified production JavaScript looks like noise: short variable names, one long line, no comments. A source map is a JSON .map file that tells the browser (and DevTools) how to reconnect that noise to your original files—App.tsx, lib/supabase.ts, the helper you wrote at 1 a.m.
MDN’s overview is still the clearest mental model: source maps map transformed code back to the original so debugging stays human (MDN: Use a source map).
Two details matter for security:
- The map URL is often advertised in the JS itself with a trailing comment like
//# sourceMappingURL=app.js.map. Anyone who can download your JS can discover the map. - Some maps embed the full original source in a field called
sourcesContent. That is the difference between “a stranger can guess your file names” and “a stranger can read your exact code, comments, and sometimes hardcoded config.”
Vibe Code Health labels the stronger case BE_SOURCEMAP_FULL and the lighter case BE_SOURCEMAP. See the glossary on /learn under “Source map.”
Why vibe-coded apps leak maps so often
AI builders optimize for “it runs.” Default templates and local vite build / next build settings that feel fine on localhost often leave maps on—or your host serves whatever landed in dist/ / .next/.
Common paths we see in the wild:
- Vite with
build.sourcemap: true(or'inline') left over from a debugging session (Vite: Build Options — sourcemap). - Next.js with
productionBrowserSourceMaps: trueturned on to chase a production bug and never turned off (Next.js: productionBrowserSourceMaps). - Copied
.mapfiles uploaded next to assets on Netlify, Cloudflare Pages, or a Replit static server because the wholedistfolder was published. - Error-tracking tutorials that say “enable source maps” without saying “upload them privately to the error service; do not leave them on your CDN.”
This is information disclosure, not a Hollywood “hack the mainframe” demo. OWASP still tracks sensitive data exposure and security misconfiguration as everyday web risks (OWASP Top Ten). A public map is closer to leaving the blueprint of your house on the porch: it does not open the door by itself, but it makes every next mistake easier.
What an attacker (or curious competitor) can do with your map
Be concrete—not dramatic:
- Read business logic you thought was “hidden” in the client (pricing rules, prompt templates, feature flags, internal route names).
- Hunt for secrets that should never have been in the client but got pasted into a component. Maps with
sourcesContentmake that search trivial. (If a live secret is in the map, rotate it—see API keys in frontend code and Supabase keys for vibe-coded apps.) - Map your private package layout (
/lib/admin/…, half-finished routes) and aim social-engineering or bug reports more precisely. - Skip reverse-engineering time. Minification is not encryption. Maps remove even that thin speed bump.
If your app only uses the browser-safe Supabase anon key and Row Level Security is correct, a map is still undesirable—but it is not the same as leaking service_role. Prioritize secrets and RLS first (Supabase RLS for beginners), then kill public maps.
Two-minute check (no tools required)
- Open your production URL (the one you share—not only the builder preview).
- View page source. Find a
<script src="…">that points at your bundle (often/assets/index-….jsor/_next/static/chunks/….js). - Open that JS URL. Scroll to the end. Look for
sourceMappingURL=…. - Open that
.mapURL in the browser.- 404 → good for public exposure (you may still upload maps privately to Sentry/similar).
- JSON with
"sources"/"mappings"→ map is public. "sourcesContent": ["…huge string…"]→ full original source is public. Fix today.
Optional: paste the same production URL into Vibe Code Health. If you see BE_SOURCEMAP_FULL or BE_SOURCEMAP, the grader already confirmed a downloadable map. Use the report’s copy-paste snippets, then re-scan.
During calibration-style passive scans of public vibe demos, full maps show up on real hosts—not only on toy fixtures—so treat this as a default checklist item before you tweet the link.
Fix it: Next.js and v0
In next.config.ts (or .js / .mjs), keep browser maps off unless you have a deliberate, private upload pipeline:
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
// Default is false — set explicitly so a future paste does not re-enable it
productionBrowserSourceMaps: false,
};
export default nextConfig;
Official behavior: when enabled, Next generates browser source maps for production debugging (Next.js docs). That is the opposite of what you want on a public marketing or SaaS URL.
After deploy:
curl -sI "https://YOUR_DOMAIN/_next/static/chunks/main-app.js.map" | head
# Expect 404 (path will vary — use the sourceMappingURL you found)
v0 / Vercel: same Next config. Redeploy from the Vercel dashboard after the commit lands. If an old deployment still serves maps, promote the new one.
Fix it: Vite (Bolt, many Lovable exports, plain React)
// vite.config.ts
import { defineConfig } from "vite";
export default defineConfig({
build: {
sourcemap: false,
},
});
Vite documents build.sourcemap as controlling whether maps are generated (Vite build options). false is what you want for a public static deploy. Avoid 'inline' in production—that embeds the map inside the JS payload.
Rebuild and redeploy the dist folder. Confirm no .map files sit next to your assets:
find dist -name '*.map'
# should print nothing
Fix it: belt-and-suspenders on Vercel
Even with generation off, you can refuse to serve maps at the edge:
{
"routes": [{ "src": "/(.*)\\.map$", "status": 404 }]
}
Put that in vercel.json if your project uses the routes form your host expects, or express the same idea with a rewrite/middleware that returns 404 for *.map. The goal is simple: no anonymous download.
If you use a paid error tracker later, follow their private upload docs (maps go to the vendor, not your public CDN). Until then, prefer “no public maps” over “convenient stack traces for everyone.”
Fix it: Lovable, Bolt, Replit (plain-language prompts)
You do not need to memorize config keys. Paste a prompt like this into the builder after you confirm a map is public:
Production source maps are downloadable. Disable browser source maps for production builds (Vite
build.sourcemap: falseor NextproductionBrowserSourceMaps: false). Remove any committed*.mapfiles from the published output. Redeploy. Confirm.mapURLs return 404. Do not put secrets in client code.
Then re-run the free scanner and make sure BE_SOURCEMAP* is gone.
Replit: prefer Secrets for credentials, and do not serve your repo root as static files if that also exposes .env or .git—those are separate critical findings covered in the pre-launch safety walkthrough.
What not to confuse with source maps
NEXT_PUBLIC_/VITE_env vars are intentionally visible in the client bundle whether or not a map exists. Maps just make them easier to read. See the API keys guide.- Supabase anon JWT in the browser can be normal; service_role never is (Supabase keys article).
- Missing security headers (CSP, clickjacking protection) are a different grade driver—common on Lovable/v0/Replit hosts. Fix maps and headers; the headers guide has copy-paste config.
A sane launch order
- Confirm HTTPS and no accidental
/.envor/.git(launch checklist). - Confirm no live secrets in JS or maps.
- Turn off public source maps; redeploy; verify 404.
- Enable RLS if you use Supabase.
- Add basic security headers when your host allows it.
- Grade the production URL and fix the top three findings first.
You do not need a security team to remove a .map file. You need five minutes, one config flag, and a habit of scanning the URL you actually share.