2

I have created a React.js app after the final production build. I have found Source code on the browser network tab on fetch:

issue

After clicking on agent_list.js it shows source js code

How to secure this one ?

Community
  • 1
  • 1
  • How would the browser read the source code if it can't read the source code? – Matt Ellen Jan 08 '20 at 13:02
  • bundle it in a single minified file.... – Jai Jan 08 '20 at 13:04
  • 4
    Do not include source maps in production deployments and only deploy the minified bundles. – crashmstr Jan 08 '20 at 13:05
  • @MattEllen Component source code display after click browser source tab display agent_list.js file http://prntscr.com/qktt3t – Rajesh Smartwebtech Jan 08 '20 at 13:06
  • Yes bundle in minified but agent_list.js component source code after click display @Jai – Rajesh Smartwebtech Jan 08 '20 at 13:07
  • i have ```npm run build``` command for production can you give me command for it @crashmstr – Rajesh Smartwebtech Jan 08 '20 at 13:09
  • 3
    What you put on the server is important. Do *not* put `.map` files from your build folder on the server, as those contain a way to map the minified chunks to the "human readable" source. – crashmstr Jan 08 '20 at 13:16
  • 1
    A final note: if you are running this locally, then being able to see the code *is expected* to allow you to debug in the browser with your original source. When you *deploy*, you do not deploy or do not allow the user to access the `.map` files so that this level of code is not visible. See: [Javascript .map files - javascript source maps](https://stackoverflow.com/q/21719562/1441) – crashmstr Jan 08 '20 at 13:32
  • I have deleted .map file but after delete it is not working error below link @crashmstr http://prntscr.com/qkuqu0 – Rajesh Smartwebtech Jan 08 '20 at 14:07
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/205608/discussion-between-rajesh-smartwebtech-and-crashmstr). – Rajesh Smartwebtech Jan 08 '20 at 14:16
  • i have got it added GENERATE_SOURCEMAP=true in env file it is working Thank you @all – Rajesh Smartwebtech Jan 10 '20 at 13:11

1 Answers1

1

Unless you did not use create-React-app (CRA), your code should be uglyfied and minified, because CRA comes with webpack by default, which handles your app bundling (even in dev mode). Otherwise I’d recommend you to research the terms between quotes to familiarize your self more with the topic.

David Buck
  • 3,752
  • 35
  • 31
  • 35