Home / patterns

Production source maps that publish your app's original source code

A developer at a desk at night looking at a monitor showing a web page beside a developer tools panel full of source code
Quick answer: Source maps translate minified JavaScript back into your original files. Next.js and Vite both leave them off for production builds by default, but AI-generated configs often switch them on (productionBrowserSourceMaps: true or build.sourcemap: true) to make errors easier to debug. Then anyone can open your site's original client-side source, comments and all, in their browser.

Last updated November 13, 2026

Steps

  1. Open your live site, open the browser's developer tools, and look in the Sources panel for your original folder names (src/, app/, components/). If you can read your own unminified code, maps are public.
  2. Or request a bundle URL with .map added (for example /_next/static/chunks/<file>.js.map). A 200 response with JSON means the map is being served.
  3. In Next.js, remove productionBrowserSourceMaps: true from next.config. In Vite, set build.sourcemap to false, or 'hidden' if you need maps for an error tracker.
  4. If you use Sentry or a similar tool, upload maps to it during the build and delete them from the deployed output instead of serving them publicly.
  5. Search your client code for anything that should never have been there (API keys, internal URLs, admin routes, TODOs about security). Source maps make these easy to find, and minification alone doesn't hide them.
  6. Rotate any secret you find in client code. Once it has been served, assume it has been copied.

Why it matters

The Next.js docs say production source maps are disabled by default to prevent leaking your source to the client, and that once enabled, Next.js automatically serves the .map files next to your JavaScript. Vite's build.sourcemap option defaults to false, and its 'hidden' setting generates maps without linking them from the bundle. Public maps hand attackers a readable copy of your front-end logic, including any client-side secrets, hidden routes and comments. MITRE classifies the underlying weakness as CWE-540, Inclusion of Sensitive Information in Source Code. Turning maps off isn't a fix for secrets in client code, though: anything shipped to the browser is readable either way, so secrets belong on the server.

Sources

Next.js docs: productionBrowserSourceMaps — https://nextjs.org/docs/app/api-reference/config/next-config-js/productionBrowserSourceMaps

Vite docs: Build options (build.sourcemap) — https://vite.dev/config/build-options

Sentry docs: Source maps for JavaScript — https://docs.sentry.io/platforms/javascript/sourcemaps/

MITRE CWE-540: Inclusion of Sensitive Information in Source Code — https://cwe.mitre.org/data/definitions/540.html

Related patterns

Found a problem you'd rather not fix yourself?

Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.

Get it fixed by StorenTech

Vibe Security Weekly

One email a week with new failure patterns and how to fix them.

By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.