Router reboot not working

I have a little problem, there are several similar questions on SA already, but I can’t figure out how to fix it. I use react-router-redux, but for this example I don’t think there are any differences from usingreact-router

I have a simple setup:

<Router history={browserHistory}>
  <Route path="/">
    <IndexRoute component={ItemList}/> 
    <Route path='item/:uuid' component={Item}/> 
  <Route>
<Router>

I use:

  • Webpack
  • Webpack-dev server
  • HTML WebPack Plugin

When I find localhost: 8080, IndexRoute is displayed. Then I can click one of the elements that has onClick={() => this.props.dispatch(routeActions.push('/item/' + item.uuid))}. The story at this stage works fine, I can go back and select another item and so on. But...

When I am on the item page, for example localhost: 8080 / item / 1234, and when I click update, I get:

404 not found - localhost:8080/item/bundle.js

, , .

, historyApiFallback: true, , , 404s will fallback to /index.html

Update:

, , localhost:8080/item/1234 - , 200 , :

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Damage Increased</title>
  </head>
  <body> 
    <script src="bundle.js"></script>
  </body>
</html>

404 http://localhost:8080/item/bundle.js

, dev , , <script src="bundle.js"></script> bundle.js /item.

+4
1

:

<script src="bundle.js"></script>

:

<script src="/bundle.js"></script>

, /item/1234, bundle.js, /item/bundle.js.

html-webpack-plugin, dev- ( ) - .

+4

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


All Articles