0

I am getting a 404 on page refresh in my angular 2 app. I have useHash set to false. I am using web-pack and it works fine in development but in production it doesn't work. I this is because in development i have

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

How can i make this work using http-server in production, without setting useHash to true?

Caroline Church
  • 203
  • 2
  • 8
  • 2
    Return `index.html` on the server for every invalid request (instead of 404) – Günter Zöchbauer Feb 27 '17 at 17:21
  • how do i do that with http-server there doesn't seem to be any options do i need to set something in my webpack.config if so what? – Caroline Church Feb 27 '17 at 17:36
  • Possible duplicate of [Angular 2.0 router not working on reloading the browser](http://stackoverflow.com/questions/31415052/angular-2-0-router-not-working-on-reloading-the-browser) – Mahin Khan Mar 01 '17 at 10:22

1 Answers1

0

I have now solved this i used spa-http-server which has a --push-state flag that makes all URIs respond with index.html.

Caroline Church
  • 203
  • 2
  • 8