2

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 1

3

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'));

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.