React-router does not match query string

My routes are defined as follows:

 <Router history={browserHistory}>
   <Route path="/" component={App}>
     <Route path="experiments">
       <IndexRoute component={Experiments} />
     </Route>
     <Route path="*" component={NoMatch}/>
   </Route>
 </Router>

When I visit /experiments, everything works as expected, and the Experiments component is displayed. However, when I manually enter the URL with the request parameters, for example:, the /experiments?offset=50route does not match!

But when I navigate with help <Link to={{ pathname='/experiments', query={offset:50} }} />, everything works as expected. The Experiments component is displayed, and this.props.location.query.offset- 50.

How do I get a route match when a URL with a query string is entered manually (or copied)?

It seems that the route should automatically match url-with-query-string-not-matching-response-router-route , but it doesn't seem to work for me.

Edit: path="*". , (, /experiments?offset=50). , , .

+4
2

historyApiFallback history={browserHistory}, , .

historyApiFallback, , index.html URL-, , index.html, URL-

-

devServer: {
    historyApiFallback: true;
}
0

, , . redux-auth, URL. , . , . URL-, /experiments?offset=50, Route .

0

Source: https://habr.com/ru/post/1664503/


All Articles