I've come across an issue which I've been trying to figure whether I'm just doing something wrong or whether it's an actual bug. After a lot of searching, I still can't figure out if I'm doing something wrong or if I've found an actual problem.
Part of the reason as to why I'm so confused is also because I found the intersection between react-router and history a bit confusing. It took me a while to figure out exactly how to use history's enhancer functions with react-router and I still think the issue might lay there.
I have a test case here:
- https://github.com/trodrigues/react-router-basename-test
- http://trodrigues.github.io/react-router-basename-test/
And the problem is:
- Clicking the button issues a this.context.router.push call to navigate to
/content/path - I'd expect it to navigate to http://trodrigues.github.io/react-router-basename-test/content/path
- Instead it navigates to http://trodrigues.github.io/react-router-basename-test/react-router-basename-test/content/path
Some additional detail:
- If I use the
<base>tag instead of theuseBasenameenhancer this works fine. However, given that I have a slightly different setup for dev and production, using an environment variable to define the basepath would be more helpful, rather than manipulating the<base>tag at build time. - The sample app I uploaded is a minimal subset of the app I'm working on. I removed everything else that didn't matter.
- The issue does not occur when running this locally with a basepath set to an empty string.