reactjsasp.net-coregoogle-developer-tools

How to stop exposing source code of react in developer tools of browser?


I'm developing project in ASP.NET Core and React. In testing, I came across one big security issue. Source files of react get expose in google developer tools. I have tried to remove webpack source maps but that thing didn't work for me and the reason is they have not mentioned in which webpack folder do we need to make change as there are 6 folder containing webpack. I'm new to this stack and not getting how to deal with this flaw. How can I fix this issue?

Screenshot of Google Developer Tools


Solution

  • Its very easy and its possible to hide complete source code which gets expose to end user in developer tools. You need to update package.json file from ClientApp folder.

    Before updation

        "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",    //UPDATE THIS LINE
        "test": "react-scripts test --env=jsdom",
        "eject": "react-scripts eject"
        }
    

    You need to use following code instead of above code:

    After updation

        "scripts": {
        "start": "react-scripts start",
        "build": "rimraf ./build && react-scripts build && rimraf ./build/**/*.map",
        "test": "react-scripts test --env=jsdom",
        "eject": "react-scripts eject"
        }
    

    Above code worked for me. This thread helped me in achieving my goal. For more details you can check that as well.