Generated files must be serviced from a web server. When you run npm run build , you should see instructions for starting a simple local web server in this directory. If you expand this directory on a real web server and feed index.html from the root, it will also work fine.
If the generated file refers to scripts without / , your site will break as soon as you add client-side routing. For example, if the application is located at mysite.com but also processes a URL, such as mysite.com/about , relative paths will load scripts from mysite.com/about/*.js , which will be 404 error. That's why all paths start with root by default.
If you want to submit your application from a subdirectory (from the example myuser.imtqy.com/myproject ), you need to add the "homepage" field to package.json , for example:
"homepage": "http://myuser.imtqy.com/myproject"
Create a React App will display the correct root path based on the homepage parameter . This feature is available because react-scripts@0.2.0
Read the deployment instructions for more information.
Dan abramov
source share