javascript source map : keeping map file local only to debug production javascript

google-chrome, javascript, source-maps

Solution

I don't believe any browsers currently allow loading source maps ondemand from local files, so you have to put the sourcemaps online somehow.

One solution could be to create a .htaccess file (or something similar, if you aren't using Apache) that restricts access to the sourcemap (and the original source files) to clients that aren't from your local network.

You should realize though, that if you want to prevent access to the sourcemaps for security reasons, then all you will achieve is a false sense of safety. Javascript is public, and even if it is minified and encrypted, it is fairly easy to unencrypt it. Do not put any sensitive data in your javascript. Not even if you minify and encrypt it.

Problem

I would like to debug production website, but I don't want to upload the map file on the server (for privacy reason, because it is public right ?). Is it possible ?

Original source