I have a react app using the following for router history.
import { BrowserRouter, Route, Link } from "react-router-dom";
import { createBrowserHistory } from "history";
<BrowserRouter history={history}>
...
This is served using Express server like this (server.js)...
//for build
// Serve the static files from the React app
app.use(express.static(path.join(__dirname, 'build')));
app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
This is working fine running locally and I can navigate to any Route successfully. Once deployed to production, If I navigate to a Route, I get
Cannot GET /Sites/SiteDashboard/
The structure of my project is as follows which is a standard CRA install...
The problem I have is pointing to the correct location on the production build to point to the index.html (or whatever) so that I can access the history like I do running locally (npm start).
Can anyone advise where I need to point to.
Thanks.