In fact, it’s normal that you get a 404 error when updating the application, since the actual address is updated in the browser (and without the # / hashbang approach). By default, HTML5 history is used for reuse in Angular2.
To fix the 404 error, you need to update the server so that it serves the index.html file for each route you specify.
If you want to switch to the HashBang approach, you need to use this configuration:
import {bootstrap} from 'angular2/platform/browser'; import {provide} from 'angular2/core'; import {ROUTER_PROVIDERS} from 'angular2/router'; import {LocationStrategy, HashLocationStrategy} from '@angular/common'; import {MyApp} from './myapp'; bootstrap(MyApp, [ ROUTER_PROVIDERS, {provide: LocationStrategy, useClass: HashLocationStrategy} ]);
In this case, when you refresh the page, it will be displayed again (but you will have # in your address).
This link can also help you: when I update my site, I get 404. This is with Angular2 and firebase .
Hope this helps you, Thierry
Thierry Templier Feb 09 '16 at 6:09 2016-02-09 06:09
source share