webpackreact-routerreact-slingshot

React slingshot - Webpack hot middleware returning 404 on hot-update.json when using react router sub-routes


Im using the react slingshot starter project for my react/redux app. Hot reload works great when I use routes like /foo but I've found that hot reload isn't working on subroutes like /foo/bar. I haven't made any changes to the out-of-the-box webpack config file, which can be found here https://github.com/coryhouse/react-slingshot/blob/master/webpack.config.js

I get 404 GET http://localhost:3004/orders/c344e97ed1fbc2923017.hot-update.json 404 (Not Found)on the CreateOrder component when I have the following routes configuration:

<Route path="/" component={App}>
    <Route path="login" component={Login} />
    <Route path="orders" component={OrderPanel} />
    <Route path="orders/create" component={CreateOrder} />
    <Route path="*" component={NotFoundPage} />
</Route>

But when I change the path from orders/create to just create, it doesn't returns a 404.

It seems like the hot update middleware is trying to fetch the hot-update.json from the /orders subroute?


Solution

  • Just for completeness and anyone having this problem with an older version of slingshot. This was also mentioned in issue 75 and fixed here by replacing:

    publicPath: '',
    

    with

    publicPath: '/',
    

    in webpack.config.js

    UPDATE: From reduckted's comment the publicPath has to start and end with a slash. Replace:

    publicPath: 'dist/',
    

    with

    publicPath: '/dist/',