Angular 2 deployed to heroku, routes only work if i navigate to root page first
5 views
Skip to first unread message
Stephan Brown
unread,
Apr 24, 2017, 10:35:07 PM4/24/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Angular and AngularJS discussion
Hi everyone,
I have an Angular 2 application deployed to heroku. I was able to get to deploy but then there's a weird issue. I'm unable to navigate to any of the routes of the application until i navigate to root first. Anyone else have had this issue before?
Sander Elias
unread,
Apr 24, 2017, 10:44:39 PM4/24/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Angular and AngularJS discussion
Hi Stephan,
You need to tweak your Heroku's settings to return your index.html instead of a 404. If you use node with express as a server add something like this:
const path =require('path'); // For all get requests, send back index.html instead of 404 app.get('/*',function(req, res){ res.sendFile(path.join(__dirname +'/dist/index.html')); });