score:2

Accepted answer

According to this reply, https://github.com/ReactTraining/react-router/issues/820#issuecomment-256814655

Using hooks (onEnter and onChange) with react-router v2 or above may achieve what you need.

score:0

Better resolve the problem from web server, like Nginx, which rewrites the url to add the trailing slash at the end of url.

score:1

Above answer will work fine and you will achieve what you need. But there is a catch. Open developers tool and click on network tab then refresh your page....you will see status 302 page redirect from WITHOUT trailing slash path to WITH trailing slash path.

And this is not very good. Atleast set status to 301.

How to set status ? https://github.com/ReactTraining/react-router/issues/458


Related Query

More Query from same tag