react-router
react-router copied to clipboard
[Bug]: Link to "/" with basename adds extra trailing slash causing SEO issues
What version of React Router are you using?
6
Steps to Reproduce
https://stackblitz.com/edit/github-aw7opq-k9k4xc?file=src%2Fmain.tsx
Use a basename in the router (for example /foo), there is no way to link to the basename without a trailing slash.
Expected Behavior
There is an option to link to the basename without a trailing slash.
Actual Behavior
Our project has a canonical URL ending without a trailing slash, this causes unnecessary redirects. There is currently no way to redirect to a basename without a trailing slash
This issue is related to https://github.com/remix-run/react-router/issues/6226, but with an additional use case.
yeah, I'm experiencing the same issue.
I'm using a V5 version, I had the same problem, But I checked it, because there was a folder name with the same name as the route in my public folder. This problem no longer occurs after I change the folder name. hope this helps.
This issue has been automatically marked stale because we haven't received a response from the original author in a while 🙈. This automation helps keep the issue tracker clean from issues that are not actionable. Please reach out if you have more information for us or you think this issue shouldn't be closed! 🙂 If you don't do so within 7 days, this issue will be automatically closed.
I believe this was fixed in 6.4.0 via https://github.com/remix-run/react-router/pull/8861. If you leave a trailing slash off the basename and then don't include one in your path you should be able to route to /foo
https://stackblitz.com/edit/github-aw7opq-vugywt?file=src%2FApp.tsx