Angular 2 refresh issue under context path

284 views
Skip to first unread message

Fabrizio Plini

unread,
Dec 22, 2016, 12:54:15 PM12/22/16
to Angular
I'm developing an angular 2 app. 
So essentialy, if I run the app with "ng serve" all works fine, if I refresh the page (for example http://localhost:4200/home) it works fine and angular recognizes the right route. 
The problem occurs when I build the app in a war and deploy it on wildfly with a different context path (ex. /myapp). At this point the routing navigation works fine but if I refresh the page I receive a "Not found error". My base href on index.html is <base href=".">
I also tried with <base href="./myapp"> but in this case angular try to look for the resources under http://myhost/ and not under http://myhost/myapp/

Anyone have any idea on how to fix it? 

Sander Elias

unread,
Dec 23, 2016, 12:01:13 AM12/23/16
to Angular
Hi Fabrizio,

Yes, fix your server so it returns the index.html instead of a 404.

Regards
Sander
Reply all
Reply to author
Forward
0 new messages