create-react-app build is not working in subdirectory on web server. I’ve used express node web server. ‘create-react-app build’ is working on root directory.But, It doesn’t work on subdirectory.
For example,
localhost/ - It works. localhost/react-app/ - It doesn’t work.
load related files normally. There are no errors and warnings. It's look like blank page. Surely I configured ‘homepage field’ in package.json. I don’t know why this situation occur. The followings are my configuration.
set express for react
app.get('/*',function(req,res){ res.sendFile(path.resolve(config.static_root+'/react-app', 'index.html')); });
add homepage field to package.json
"homepage": "localhost/react-app"
npm run build
copy files form build folder and move to /react-app folder.
http://localhost/react-appinto the homepage field? I'm not sure it would get parsed correctly without the protocol. - Dan Abramov