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!
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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
adding new file
Click on .htacess file and then select edit to edit it