0

When I navigate to http://localhost:8080 the products page displays, as expected. However, when navigating to http://localhost:8080/basket I get the message in the browser:

Cannot GET /basket

Here is my routes.js:

import React from 'react';
import { AppContainer } from 'react-hot-loader';
import { Router, Route, browserHistory, IndexRoute } from 'react-router';
import store from './store/store.js';
import { Provider } from 'react-redux';
import Error404 from './components/Error404.jsx';
import App from './containers/App.jsx';
import ProductsArea from './containers/shop/ProductsArea.jsx';
import BasketArea from './containers/shop/BasketArea.jsx';

const routes = () => (

    <AppContainer>
        <Provider store={store}>
            <Router history={browserHistory}>
                <Route path="/" component={App}>
                    <IndexRoute component={ProductsArea} />
                    <Route path="basket" component={BasketArea} />
                </Route>
                <Route path="*" component={Error404} />
            </Router>
        </Provider>
    </AppContainer>

);

export default routes;

1 Answer 1

2

I added historyApiFallback: true to my webpack.config.js file:

module.exports = {
    ...
    devServer: {
        historyApiFallback: true,
        hot: true,
        contentBase: path.resolve(__dirname, 'dist'),
        publicPath: '/'
    },
    ...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.