I have created my website but it shows all of its source code into browser's source code static files section. It is not secured and i want to remove all of the data. My application is created in react.js and feathers.js
Asked
Active
Viewed 1,071 times
1
-
Possible duplicate of [How do I hide javascript code in a webpage?](https://stackoverflow.com/questions/6869312/how-do-i-hide-javascript-code-in-a-webpage) – VLAZ Oct 23 '19 at 07:07
-
1Possible duplicate of [How can I obfuscate (protect) JavaScript?](https://stackoverflow.com/questions/194397/how-can-i-obfuscate-protect-javascript) – Agney Oct 23 '19 at 07:07
-
When you say source code do you mean JavaScript? – sydeng Oct 23 '19 at 07:08
-
We'd really have to know a lot more about what you're doing and what exact problem you are observing. Javascript that runs in the browser will ALWAYS be visible to anyone. That is a function of the browser architecture. Code that needs to be private must be on the server and the client makes requests of the server to run that code. A properly configured server will not expose any of its code to any browser. There is no way to prevent client-side code that runs in the browser from being seen. – jfriend00 Oct 23 '19 at 07:08
-
Use name mangling when you're minifying your js files. And don't serve the `.map` files in production. The code will still be visible to everyone but it will be very hard to know what it does. – xyres Oct 23 '19 at 07:36
2 Answers
1
There are many ways to hide/remove source code from browser.
But I like to add GENERATE_SOURCEMAP=false
with build command in package.json file. it will not generate .map files which have source code.
"scripts": {
"start": "react-scripts start",
"build": "GENERATE_SOURCEMAP=false react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
Remember there is no (&&) operator between GENERATE_SOURCEMAP=false
and react-scripts build

Manoj Kumar
- 808
- 9
- 15
0
You may want to check if your build is properly minified or not. Creating a production build would bundle and minify the files which helps to protect the source code.
Refer this thread - https://github.com/facebook/create-react-app/issues/4162

Swap D
- 93
- 5