DEV Community

Discussion on: Your React Codes Might Not Be In Safe!

Collapse
 
artidataio profile image
Imaduddin Haetami • Edited

I didn't do what you ask us to do to keep safe, but my codes are already transpiled in the web. Perhaps you can elaborate more on why it is not safe.

Collapse
 
tayfunerbilen profile image
Tayfun Erbilen

because of source map files, if you don't have, then you safe. otherwise look my example that I gave, you will see why you are not safe.

Collapse
 
artidataio profile image
Imaduddin Haetami • Edited

I have looked at your example, the source code can be seen with our naked eyes. Why it is not safe?

Thread Thread
 
tayfunerbilen profile image
Tayfun Erbilen

maybe "safe" is a wrong word because of my english, I'm trying to say, everybody can access your js file, but if you access like this, this is not cool, at least for me.

Collapse
 
apo-bozdag profile image
Abdullah Bozdağ

example: maybe you are using a paid service and the api key may be clearly visible.

Collapse
 
artidataio profile image
Imaduddin Haetami

That's not how api key stealing works, it will be bots looking for keywords like fetch. Besides you shouldn't have any secret like api key on your client app like React. Instead, you should build a proxy server with permission only to your app, and that's where you use your api key.
CRA already warn you on this:
create-react-app.dev/docs/adding-c...
Read more here:
stackoverflow.com/questions/468380...
unicorn-utterances.com/posts/keepi...

Thread Thread
 
tayfunerbilen profile image
Tayfun Erbilen

some people forgetting private infos in a comment. when they get build they know comments will remove, but not in source maps. so this might be a problem for someone