Home > Software design >  Components are accessable via console on production?
Components are accessable via console on production?

Time:02-11

I recently deployed a website for a friend of mine, written in react, express, mongodb, etc... And I can see that I have a console.log on one of the components and wanted to ask if that's normal that a component is accessable via a console.log? (I can access the source code because of that).

And is there a solution for that or just removing ALL console.log before production?

Thank you very much, God bless.

CodePudding user response:

Assuming you used create-react-app to start the project, it generates sourcemaps when you run the build script by default. You can disable this by adding GENERATE_SOURCEMAP=false in your .env file.

As for the console logs, you can either change console.log to console.debug (which only shows in the browser console when you have verbose logging enabled) or you can rely on some linting rule (like this) to prevent the use of console altogether.

  • Related