I am trying to host an angular 2 application (created using angular cli) with Firebase, but my routes do not work.
I created a project with angular 2 and typescript for the site I'm working on, where I need a static privacy policy page.
When i do
ng serve
and go to http: // localhost: 4200 / privacy-policy in my browser. I get the content that I expect.
Here is the code recommended on the angular 2 route page -
@NgModule({ declarations: [ AppComponent, HomeComponent, TermsOfServiceComponent, PrivacyPolicyComponent, PageNotFoundComponent ], imports: [ AlertModule, BrowserModule, FormsModule, HttpModule, RouterModule.forRoot([ {path: 'privacy-policy', component: PrivacyPolicyComponent}, {path: 'terms-of-service', component: TermsOfServiceComponent}, {path: '', component: HomeComponent}, {path: '**', component: PageNotFoundComponent} ]) ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }
I set up Firebase hosting with my project, here is my configuration file -
{ "database": { "rules": "database.rules.json" }, "hosting": { "public": "dist" } }
For deployment, I ran
ng build --prod firebase deploy
When I go to https://MY-APP.firebaseapp.com/ the application loads fine for the default route.
However, when I try to go to https://MY-APP.firebaseapp.com/privacy-policy I get 404.
I would expect this to work the same way as with ng.
Any help would be greatly appreciated.
angular firebase firebase-hosting
Philip brack
source share