I'm configuring react-boilerplate to start a project on it.
Our dev environment publishes "dev" versions of the app in sub paths, for example: example.org/test/project-name
Then, when we publish the project, it stays on example.org/
I'd like to use the browser history (HTML5 API) and not the hash history. But this means that I have to set the basename
of React Router to match the current environment.
Right now, I'm trying to set up a static basename in this way:
const browserHistory = useRouterHistory(useBasename(createHistory))({
basename: '/test/project-name',
});
const store = configureStore(initialState, browserHistory);
But when I run the application, the homepage is still at /
instead of /test/project-name/
.
So, the questions are:
- What am I doing wrong?
- How would you make the basename match the current environment?