Answer the question
In order to leave comments, you need to log in
Why does the React project not work after uploading to the hosting?
This is my first time hosting a React site. I used to abandon sites written in pure JS and everything was ok. Abandoned React site to hosting my.aiwebhost.com.
And instead of a website, I have this:
I think perhaps the reason is that index.js is in the src folder, and not in the main folder, initially npm threw index.js into the src folder when creating the project. I tried moving the index.js file to the main folder of the project, and now I have this displayed:
Perhaps some additional settings are needed on the hosting? Or how to fix my problem?
Or maybe some special hosting is needed for react projects?
Answer the question
In order to leave comments, you need to log in
When your app is ready to be deployed to production, running npm run build will create an optimized build of your app in the build folder.
reactjs.org
Exactly after fill does not work? And before you have to pay more, you also opened it exactly index.js in the browser and not a ready-made build and not a dev server, and at the same time it worked? If not, then maybe it didn't work after filling.
Depending on how you set up your npm scripts and your builder, the commands in the previous answers may not work. If I understand correctly, then your assembler collects the bundle in the public folder (and your index.html is also there) and it is its content that needs to be uploaded to the hosting. All other code before the assembly is not needed, because the assembler still assembles it into a bundle. The most important thing is that index.html should be at the root, the server sends it to the browser by default, after which the browser downloads all the files that are described in the index file.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question