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…


This content originally appeared on DEV Community and was authored by Tayfun Erbilen

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 :)


This content originally appeared on DEV Community and was authored by Tayfun Erbilen


Print Share Comment Cite Upload Translate Updates
APA

Tayfun Erbilen | Sciencx (2021-11-14T22:48:27+00:00) Your React Codes Might Not Be Safe!. Retrieved from https://www.scien.cx/2021/11/14/your-react-codes-might-not-be-safe/

MLA
" » Your React Codes Might Not Be Safe!." Tayfun Erbilen | Sciencx - Sunday November 14, 2021, https://www.scien.cx/2021/11/14/your-react-codes-might-not-be-safe/
HARVARD
Tayfun Erbilen | Sciencx Sunday November 14, 2021 » Your React Codes Might Not Be Safe!., viewed ,<https://www.scien.cx/2021/11/14/your-react-codes-might-not-be-safe/>
VANCOUVER
Tayfun Erbilen | Sciencx - » Your React Codes Might Not Be Safe!. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/11/14/your-react-codes-might-not-be-safe/
CHICAGO
" » Your React Codes Might Not Be Safe!." Tayfun Erbilen | Sciencx - Accessed . https://www.scien.cx/2021/11/14/your-react-codes-might-not-be-safe/
IEEE
" » Your React Codes Might Not Be Safe!." Tayfun Erbilen | Sciencx [Online]. Available: https://www.scien.cx/2021/11/14/your-react-codes-might-not-be-safe/. [Accessed: ]
rf:citation
» Your React Codes Might Not Be Safe! | Tayfun Erbilen | Sciencx | https://www.scien.cx/2021/11/14/your-react-codes-might-not-be-safe/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.