Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
November 14, 2021 10:48 pm GMT

Your React Codes Might Not Be Safe!

If you are using create-react-app for creating react applications and using yarn build to get build, your react codes might not be safe.

Because, if you run yarn build command without any spesification, it will generating source maps as well.

And if you put builded files without deleting source maps to your server, anyone can see your entire react project codes.

How bad is it?

If you go this website, https://svgeditoronline.com/editor/ and open developer tools, and select "Sources" tab. Then you will able to see all project codes sadly.

Image description

What we have to do?

We have to delete .map files from builded files which is in build/static/js folder.

And for the next build you should change your package.json build command

find this line

..."build": "react-scripts build",...

change with this

..."build": "GENERATE_SOURCEMAP=false react-scripts build",...

Now, your code is safe. This is a small but important think.

I checked a lot of live react project, also checked selling react scripts on codecanyon, and guess what I found? Almost every project left .map files in static/js folder.

TL;DR

  • Delete all your .map files from build/static/js folder.
  • Change your build command on package.json from this "build": "react-scripts build", to this "build": "GENERATE_SOURCEMAP=false react-scripts build", for your next builds.
  • Now you are safe, I hope :)

Original Link: https://dev.to/tayfunerbilen/your-react-codes-might-not-be-safe-8lc

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To