2

I am deploying my React app on a public server but when I open it I just get the blank page.

In order to deploy the app I did:

1) run "npm run build" to minify the code and putting into a build folder
2) replaced the local URL in the new index.html file with the correct server ones.

still, when trying to open the website in the console I get these errors.

error image

Any ideas?

Enrico
  • 787
  • 12
  • 28
  • can we see how you access these resources in your App? Maybe related to [this](https://stackoverflow.com/questions/49905882/refused-to-execute-script-because-its-mime-type-text-html-is-not-executable/49913501) and [that](https://stackoverflow.com/questions/40574159/refused-to-execute-script-strict-mime-type-checking-is-enabled). – v-gael Jul 26 '18 at 06:16
  • i basically replaced the local URL, which pointed to the original React folder, to the new folder in the server. src="./public_html/static/js/main.f5239b39.js" – Enrico Jul 26 '18 at 06:18
  • you changed the minified version of your index html to point script adresses somewhere else on the server ? – Jayffe Jul 26 '18 at 06:24
  • Check if your `` and `` element have the expected `type` – v-gael Jul 26 '18 at 06:25
  • @Jayffe, yes, I addressed on the server folder which is named public_html, where I stored the applicaton itself – Enrico Jul 26 '18 at 09:46
  • @v-gael what would would it the expected type be? – Enrico Jul 26 '18 at 09:46
  • `type="text/javascript"` for your js file, it seems for a reason the type is `text/html` – v-gael Jul 26 '18 at 09:51
  • shoul I just add type="text/javascript" somewhere in the body of the index.html file? – Enrico Jul 26 '18 at 09:55
  • in your javascript tag: `` – v-gael Jul 26 '18 at 12:27

2 Answers2

2

I solved the problem simply correcting the url.

since I was already accessing the "public" folder thanks to the "./" typing in the beginning of the url, there was no need to type "./public".

Thank you anyway.

Enrico
  • 787
  • 12
  • 28
1

Just edit webpack config by editing this:

     devServer: {
       historyApiFallback: true
          }

And also add this to public/index.html:

  <base href="/" />

Hope this help

Adnan
  • 1,589
  • 11
  • 17
  • Do you mean the webpack string in the package.json? if not, where? also, do you mean i should enclose every href in the base tag? – Enrico Jul 26 '18 at 13:10
  • 1
    Webpack configuration in webpack.config file and you need to change base tag only in index.html file not every file – Adnan Jul 26 '18 at 15:13