Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Deploy react project to Heroku without source code showing?

I have a react project I am trying to deploy to heroku. I did so by installing the react buildpack however when I go to the website, open inspect element, all my client side source code is simply exposed to all public view. What am I doing wrong, I cannot find any help which addresses this issue but it is quite the security flaw. Help me understand, because I know I did something wrong and it should not be this way. Thanks!

All the files of my project when you open dev tools and go to sources

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Change the build script to include GENERATE_SOURCEMAP=false so that the build commands follow it. This is an intended effect according to this

gaearon

This is expected. You can delete .map files from the build output if
you want to disable it, although you’ll get console warnings about
them missing.

There is no harm in leaving them in though in my opinion. Client code
is already available to the user’s machine so there’s no secrets in
it.

scripts: {
  "build": "GENERATE_SOURCEMAP=false react-scripts build"
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading