Monday 8 May 2017

How to serve 404 page in Node js + Express App on html5mode(true)?

I configured App routing with $stateProvider along with html5Mode. To prevent 404 error on page refresh on html5Mode i configure a route as below in express.

app.all('*', function(req, res, next) {
  res.sendFile('./public/index.html', { root: __dirname });
});

with above statement i'm unable to show the 404 page, because all unmatched routes finally serving by above code.



via Hearaman

No comments:

Post a Comment