I can not understand how to configure routes in Angular2 + Express . I angular2 trying to deploy my angular2 project on the server. The server gives the user index.html . All routes work. If the reload page appears 404. I understand that somehow you need to pass routes from express to angular . But nowhere can I find how this is done. Kick in the right direction. The solutions found do not work due to the lack of ROUTER_PROVIDERS .

  • express should give index.html to all requests, then the angular will figure out itself. the only exceptions are data requests - Grundy
  • Thank. Corrected express. Added processing of all required requests. - Anatoly Ponomarev
  • problem solved? - Grundy
  • Yes. Thank. It is not clear how angular handles routes. - Anatoly Ponomarev
  • instead of adding to the headline, just accept your own answer: check mark next to the answer - Grundy

1 answer 1

The problem was solved by adding all routes to the express server.

 var renderIndex = function (req, res) { res.sendFile(path.resolve(__dirname, 'index.html')); }; app.get('/*', renderIndex);