react-router icon indicating copy to clipboard operation
react-router copied to clipboard

[Bug]: Link to "/" with basename adds extra trailing slash causing SEO issues

Open cornedor opened this issue 3 years ago • 2 comments

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.

cornedor avatar Mar 08 '22 13:03 cornedor

yeah, I'm experiencing the same issue.

BlazeIsClone avatar Mar 20 '22 13:03 BlazeIsClone

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.

codence-x avatar Mar 23 '22 09:03 codence-x

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.

github-actions[bot] avatar Apr 25 '23 00:04 github-actions[bot]

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

brophdawg11 avatar Jan 18 '24 22:01 brophdawg11