I used react-router-dom
and I build my react-app. When I deploy it on the server, I get a blank page and the console is empty.
My App.js is :
Try changing basename="/"
on your BrowserRouter
to basename="/React"
. react-router
needs this if used in a sub-directory.
From the react-router docs:
basename: The base URL for all locations. If your app is served from a sub-directory on your server, you'll want to set this to the sub-directory. A properly formatted basename should have a leading slash, but no trailing slash.
Also change homepage
in package.json
to the url of your production target. homepage="."
means it will work on every domain where it is located in the server root (and is also the default behaviour).
From the React docs regarding deployment:
By default, Create React App produces a build assuming your app is hosted at the server root. To override this, specify the homepage in your package.json, for example:
"homepage": "http://mywebsite.com/relativepath",
This will let Create React App correctly infer the root path to use in the generated HTML file.