Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 刷新时角度404_Angular_Webpack - Fatal编程技术网

Angular 刷新时角度404

Angular 刷新时角度404,angular,webpack,Angular,Webpack,我在angular 2应用程序中获得404页面刷新。我已将useHash设置为false。我正在使用WebPack,它在开发中运行良好,但在生产中不起作用。我认为这是因为我在发展中 devServer : { port : METADATA.port, host : METADATA.host, historyApiFallback : true, watchOptions : { aggregateTimeout : 300, poll : 1000 } }

我在angular 2应用程序中获得404页面刷新。我已将useHash设置为false。我正在使用WebPack,它在开发中运行良好,但在生产中不起作用。我认为这是因为我在发展中

devServer : {
  port : METADATA.port,
  host : METADATA.host,
  historyApiFallback : true,
  watchOptions : {
    aggregateTimeout : 300,
    poll : 1000
  }
},

如何在生产环境中使用
http服务器
,而不将useHash设置为true来实现这一点?

我现在已经解决了这个问题,我使用了
spa http服务器
,它有一个
--push state
标志,使所有URI都用index.html响应。

在服务器上为每个无效请求返回
index.html
(而不是404)我如何使用http服务器来实现这一点似乎没有任何选项我需要在我的webpack.config中设置一些内容吗?如果需要,什么?可能的重复