Reputation: 307
I have a built a React application and it runs fine from the local server. However, when I run npm run build, the process appears to execute correctly (creates build folder, which contains the bundled js file and the index.html file), but when I open index.html in my browser it renders nothing. I read something about static server to use node.js, the problem is, Im paying hostgator and to use a static server I need to pay for month almost the amount that Im paying for year, there is some way to run it on a server without node, apache etc? (because the project is already done)... Thanks guys appreciate!
Upvotes: 2
Views: 2624
Reputation: 11830
On the place you are putting your build file (screenshot at last)
You need to create .htacces
file
Copy and paste this content in that .htacces
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
It should probably work now.
[Note:] Try creating it using file
option in your Cpanel and once it is created, edit .htacess file and paste the above code snippet (3rd and 4th Image).
Something like this
Where .htacess file looks like this
Click on .htacess file and then select edit to edit it
Upvotes: 2