DEV Community

Discussion on: Truly Protected React Routes

Collapse
 
sudonitin profile image
Nitin Sahu

Interesting read! although we can hide all the sources(files, components, redux, etc)
by just adding a single line in our package.json file. This hides all the source maps when we make a production version of our application.

The line is:
"build": "GENERATE_SOURCEMAP=false react-scripts build"

Read about it here:
stackoverflow.com/questions/514157...

Collapse
 
daggala profile image
Daggala Gudmundsdottir

thanks for your reply! I definitely should have mentioned that in the article... and also that react dev tools could be disabled in production as well!

Just clarifying for possible future readers that even though you disable the sourcemap and react dev tools, you will still have access to the css files and javascript and you can find ways to do the same hack that is demonstrated in the blog

Collapse
 
sudonitin profile image
Nitin Sahu

Hmmmm... I see. Thanks for the amazing article though!

Thread Thread
 
daggala profile image
Daggala Gudmundsdottir • Edited

You don't seem entirely convinced :) But if you go to the webpage of you react app, you go to the source of your index.html that you can see in chrome dev tools -> Network tab. You could scroll down to the script tags <script src="/static/js/main.b5b80c7f.chunk.js"> open it and you'll see that you have access to all the minified javascript chunk. The browser needs to run this javascript so sadly it is accessible to the user. It is however minified so it would be harder to do this hack in my article, but it's possible anyways. (I show here an example on localhost but this would also work on production)

Thread Thread
 
sudonitin profile image
Nitin Sahu

It's not like I was not convinced.. 😂
I was curious about it and searched for more regarding this and found exactly what you've mentioned in this thread.
Kudos to you... 🔥🔥
I would've not paid attention anytime soon to this detail if it wouldn't have been your article.

Thread Thread
 
daggala profile image
Daggala Gudmundsdottir

hahah ^^ I see! lovely to hear, thank you :)