How to tell webpack dev server to serve index.html for any route

后端 未结 10 2063
心在旅途
心在旅途 2020-11-28 22:00

React router allows react apps to handle /arbitrary/route. In order this to work, I need my server to send the React app on any matched route.

But webpa

10条回答
  •  遥遥无期
    2020-11-28 22:29

    historyApiFallback option on official documentation for webpack-dev-server explains clearly how you can achieve either by using

    historyApiFallback: true
    

    which simply falls back to index.html when the route is not found

    or

    // output.publicPath: '/foo-app/'
    historyApiFallback: {
      index: '/foo-app/'
    }
    

提交回复
热议问题