Why does react-routing not work directly in the browser?

177 Views Asked by At

I am using react-router 2.0 in my universal react app. Navigation trough the Link component works but when I paste the url manually nothing happens(browser hangs). How can I fix this issue? This is the router code:

<Route path="/" component={App}>
  { /* Home (main) route */ }
  <IndexRoute component={Home}/>

  { /* Routes requiring login */ }
  <Route onEnter={requireLogin}>
    <Route path="chat" component={Chat}/>
    <Route path="loginSuccess" component={LoginSuccess}/>
  </Route>

  { /* Routes */ }
  <Route path="about" component={About}/>
  <Route path="login" component={Login}/>
  <Route path="pagination" component={Pagination}/>
  <Route path="survey/:user" component={Survey}/>
  <Route path="widgets" component={Widgets}/>
  <Route path="search" component={Search}/>
  <Route path="make/model/:id" component={Details}/>
  { /* Catch all route */ }
  <Route path="*" component={NotFound} status={404} />
</Route>
1

There are 1 best solutions below

1
On

try this in your routes

add "/" in all routes like this

<Route path="/about" component={About}/>