Skip to content
Leakwise

Are my source maps public, and how do I turn them off?

Open one of your JavaScript bundle URLs and add .map to the end. If a file downloads, your source maps are public and anyone can read your original source code. Turn them off in your build config, or upload them to Sentry privately and do not deploy them.

What is a source map?

Browsers run minified JavaScript, which is hard to read. A source map (a .js.map file) links that code back to your original files. It is useful for debugging. If it is public, anyone can download it and read your original source, including comments, file names and internal API routes. That makes it much easier to hunt for bugs and hardcoded keys.

How do I check if my source maps are public?

  1. Open your site, then DevTools, then the Network tab, and reload.
  2. Click a .js file. Copy its URL.
  3. Open the same URL with .map added to the end.

Or use curl:

curl -I https://your-site.com/assets/index-abc123.js.map

A 200 response with a large file means the map is public. You can also look at the last line of a bundle for a //# sourceMappingURL= comment. Note that some servers return a 200 HTML page for unknown paths, so open the result and make sure it is JSON.

How do I turn source maps off?

Next.js

Browser source maps are off by default. The setting is productionBrowserSourceMaps. If it is on in your config, remove it or set it to false:

// next.config.js
module.exports = {
  productionBrowserSourceMaps: false,
};

Vite

// vite.config.js
export default {
  build: { sourcemap: false },
};

Create React App

GENERATE_SOURCEMAP=false npm run build

After you rebuild and deploy, run the check again. Also clear your CDN cache, since old .map files can stay cached.

Can I keep source maps for error tracking?

Yes. Upload the maps to Sentry during your build, and do not deploy them to your public host. Sentry uses them to show readable stack traces. Use Sentry's build plugin or CLI for your framework, then delete the .map files from the build output before you publish. A setting that generates maps without the sourceMappingURL comment is not enough on its own, because the files may still be served if you deploy them.

Source maps are a small leak, not a breach. They matter most when other problems exist. Read the 10-minute security check for the rest.

Check your app

The free scan reads only what a browser downloads and takes under a minute. For a person to review your code, there is a human audit.