webpack-dev-server react-router push state

前端 未结 2 1729
借酒劲吻你
借酒劲吻你 2021-01-11 11:42

I am trying to get react-router to work with webpack-dev-server but keep getting cannot Get /SOMEURL. This is because webpack-dev-server is looking for that specific file bu

相关标签:
2条回答
  • 2021-01-11 12:06

    Use the --history-api-fallback option to webpack-dev-server. This uses connect-history-api-fallback to serve up index.html if the route doesn't match any other files. (This does mean you have to use index.html as the filename for your HTML page.)

    0 讨论(0)
  • 2021-01-11 12:09

    For me, i had this in my index file:

    <script src="./assets/app.js"></script>
    

    rather than

     <script src="/assets/app.js"></script>
    

    So, it looks like the history fallback API was in competition with my misconfiguration.

    0 讨论(0)
提交回复
热议问题