I have deployed my Angular2 app on Heroku and all works just fine, but only when I use my the "www.example.com" format, if I digit "www.example.com/page" on the search bar it gives me the "cannot GET /page", on local it all works, but on Heroku not, what can I do to make it work?
1 Answer
I got that when I uploaded a small app that I made to heroku. My quick fix was to add the hashbang to urls so the server did not pick up the routes. Just add this to your app.module.ts where you import routes:
RouterModule.forRoot(ROUTES, {useHash: true})
Also in your node server you can add this to your index file to always send by the client index.html file if you don't want to use the hash in your routes.
app.use((req, res)=>res.sendfile(__dirname + '/public/index.html'));