tmp dev
tmp dev

Reputation: 9219

react-router, routes not working

I am using the react-router and I have the following routes

<Route path = '/' component = {App}>
    <Route path = '/login' component = {LoginContainer}>
    </Route>
</Route>

Now from the app when I go to 'http://localhost' then it works fine, however when I navigate to http://localhost/login then I get an error saying login cannot be found.

Upvotes: 0

Views: 334

Answers (1)

Jo Peyper
Jo Peyper

Reputation: 390

If you're using webpack dev server, you will need to use the History API Fallback option if you want to use browser history.

Basically, when you go to http://localhost/login, the dev server does not have anything at that address to serve you, so you need to tell it to fallback to your index to allow it to load the correct route.

Upvotes: 1

Related Questions