Search code examples
firebasefirebase-hosting

#AskFirebase Toggle source map on/off on firebase hosting


Is there any way I can upload the source maps to firebase hosting, and enable\disable them by demand?
I don't want to reveal my source maps on production, but if there's a specific error on production env, I'd like to turn source maps on. Can this be acheived through cli\api\console?
I was thinking of adding a redirect rule to redirect all source maps requests to a non existent path, but what I cannot figure out is how to enable source maps again. How do I update only the firebase.json to fix the broken source map links?


Solution

  • I finally came up with a solution that satisfies me and I wrote an article that describes in details how to do it.

    The gist is:

    1. Before you deploy your code, move all /static/*.map files to a new secret directory inside your build folder
    2. In firebase.json rewrite all /static/*.map requests to a cloud function.
    3. Write the function where you can decide whether to redirect to real location of sourcemaps or return 404