Leaked source maps: anyone can read your site's original code. How to check and close it
Updated · by the Bologu team
When you build a site, tools like React or Vue squeeze your code into long, hard-to-read lines. Many of them also write a second set of files ending in .map. These are source maps: they make debugging easy, and they usually contain your original source, every file, comments included. If they go online with the site, anyone can open them, and an AI can work out your pricing or internal logic from them in minutes.
It has happened to big companies
On 31 March 2026 someone noticed that version 2.1.88 of the Claude Code package on npm shipped with a source map, which put the tool’s full TypeScript source up for anyone to download: about 1,900 files and some 512,000 lines, according to news reports. No hack was involved, just one setting left on while packaging. Ordinary websites make the same mistake even more easily.
Which tools publish source maps unless you say no
- Create React App: generates them for production builds by default; set
GENERATE_SOURCEMAP=falseto stop it. - Vue CLI:
productionSourceMapdefaults totrue. - Vite (including Lovable and Bolt projects) and Next.js: off by default. They leak only when someone turns them on, e.g. to debug, and forgets.
Check it yourself in 2 minutes
- Open your site, press F12 and go to Sources. Folders like
src/with readable.tsxor.vuefiles mean source maps are there. - Open one of your JS files (Network → JS) and scroll to the end. If there is a
//# sourceMappingURL=…line, open that URL directly: if it downloads, it leaks.
Turn them off in the right place
Create React App .env: GENERATE_SOURCEMAP=false
Vue CLI vue.config.js: productionSourceMap: false
Webpack webpack.config: devtool: false (production)
Vite vite.config: build.sourcemap → leave it out, or false / "hidden"
Next.js next.config: productionBrowserSourceMaps → leave it outThen build and deploy again. That isn’t the end, because of two things people forget:
- Old files stay behind: hosts where you upload files yourself (FTP, cPanel, S3, R2) don’t delete old ones. Delete every
.mapfile by hand, then purge your CDN cache (e.g. Cloudflare → Caching → Purge Everything). - Assume the code was read: search it for API keys, tokens or passwords that were in those files, and rotate any you find in that provider’s settings right away. Deleting the file doesn’t un-leak a key someone already saw.
If you still need source maps for debugging
Use hidden maps (Vite has "hidden") and upload them to Sentry or your error tool at build time, not to the site. If you upload files to your host yourself, our Harden tool minifies the JS and can put a decoy source map in place of the real one, so an AI that downloads the map gets fake code. To be clear: that only slows people down. Someone determined can still read minified code.
What turning off source maps doesn’t fix
Code sent to the browser can always be read; minified or not, an AI can help unpick it. Prices, discounts, permission checks and every secret must live on the server. If your site calculates prices in the browser today, open F12 → Console and change a price before checking out. If the order goes through, that logic has to move to the server.
Prompt to have your AI fix it
Check whether my production build publishes source maps (.map files) to the browser.
1. Tell me which build tool this project uses and where its production source-map setting is.
2. Turn source maps off for production (Create React App: GENERATE_SOURCEMAP=false; Vue CLI:
productionSourceMap: false; Webpack: devtool false; Vite: no build.sourcemap: true;
Next.js: no productionBrowserSourceMaps). If we upload maps to Sentry, keep them
"hidden" and make sure the deploy step does not upload the .map files to the site.
3. Search the source for API keys, tokens and passwords that would have been readable in
the maps, and list them so I can rotate them.
4. List any pricing, discount or permission logic that runs in the browser, so we can
move it behind the server.
Show me every file you changed.Let Bologu check
The website scan (free) follows the JS files your page loads, opens any source map they point to and tells you whether original source is exposed. It also warns when browser code is easy to read and contains business logic. A decoy map from Harden shows up as a note, not as a problem.
Sources
- OWASP WSTG-INFO-05: Review Web Page Content for Information Leakage
- Create React App: Advanced Configuration (GENERATE_SOURCEMAP)
- Vue CLI: Configuration Reference (productionSourceMap)
- Vite: Build Options (build.sourcemap)
- Next.js: productionBrowserSourceMaps
- InfoQ: Anthropic Accidentally Exposes Claude Code Source via npm Source Map File
Read next
- npm malware wave of 2026: why AI-built sites are at risk, and how to protect yours
- Next.js ships security patches almost monthly: which version you need now (Nov 2026)
- Lessons from Moltbook: a fully AI-built site that let anyone read and edit its database
- Admin API leaking in your JavaScript: why lazy loading doesn't help, and where to fix it
- Is Lovable safe? Security risks and how to check your app
- Vibe coding security checklist: 20 checks before you launch
- Supabase RLS explained: fixing “RLS Disabled in Public”
- API key leaked in your website: how to check, and what to do right away
- Forgotten subdomains: how strangers can take over pages on your domain
- Secure your Claude Code, Codex and Cursor settings: stop clicking "allow all"
