Angular2 Hero Routing

I have an angular2 application in heroku and am having problems with the router. In the local host everything works like a charm, but when I deploy to the hero and try to access on any route that is not an index, I got a 404 error if I go along the index and then go to the pass page, routing works fine if I if I don’t reload the page, then I get another 404, here is a piece of my .json package used by the hero. "heroku-prebuild": "npm install http-server -g", "heroku-postbuild": "ng build --target=production --environment=prod && rsync -a dist/* .", "start": "http-server dist/", Do I need to configure any express account that will be used in my Procfile?

+4
source share
1 answer

, , angular , . index.html. ,

app.get('*', function (req, res) {
  res.sendfile('./dist/index.html'); // load our index.html file
});

404, . i.e index.html angular , .

+1

Source: https://habr.com/ru/post/1660211/


All Articles