Running Angullar 2 on http-server

0

I have an application in Angular2 and it was generated / dist where it contains the HTML code, CSS and Javascript I executed the code using http-server and tomcat. My problem is that when I rotate my routes it stays like this - > link but the problem is when I give refresh on the page it does not find it would have to add '# /' example: link

    
asked by anonymous 29.08.2017 / 15:44

2 answers

0

I was able to resolve by adding within / dist the .htaccess folder <IfModule mod_rewrite.c> Options Indexes FollowSymLinks RewriteEngine On RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.html [L] </IfModule>

    
29.08.2017 / 15:59
0

To use routes without HTML5 mode using hashbang, you need to do this in your main route module:

...
imports: [
  ...
  RouterModule.forRoot(routes, { useHash: true })
  ...
]
...

According to doc: Appendix: LocationStrategy and browser URL styles

    
29.08.2017 / 16:14