I Have an Angular application. I run the command ng build --prod --aot
to generate the dist folder.
In the dist folder I created a file named Staticfile then I uploaded the dist folder to pivotal.io with the following commands:
The app runs well. I have a nav bar, so when I change the path with navbar everything works fine. But when I do it manually (I enter the url myself) I have this error 404 Not Found nginx. This my app.component.ts:
const appRoutes: Routes = [
{ path: 'time-picker', component: TimePickerComponent },
{ path: 'material-picker', component: MaterialPickerComponent },
{ path: 'about', component: AboutComponent },
{ path: 'login', component: LoginComponent },
{ path: 'registration', component: RegistrationComponent },
{
path: '',
redirectTo: '/time-picker',
pathMatch: 'full'
}
];
@NgModule({
declarations: [
AppComponent,
TimePickerComponent,
MaterialPickerComponent,
DurationCardComponent,
AboutComponent,
LoginComponent,
RegistrationComponent,
],
imports: [RouterModule.forRoot(
appRoutes
// ,{ enableTracing: true } // <-- debugging purposes only
),
FormsModule,
BrowserAnimationsModule,
BrowserModule,
MdCardModule, MdDatepickerModule, MdNativeDateModule, MdInputModule
],
providers: [{ provide: DateAdapter, useClass: CustomDateAdapter }],
bootstrap: [AppComponent]
})
export class AppModule {
constructor(private dateAdapter: DateAdapter<Date>) {
this.dateAdapter.setLocale('fr-br');
}
}
I finally found the answer: After I generated the dist folder.
pushstate: enabled
pushstate enabled keeps browser-visible URLs clean for client-side JavaScript apps that serve multiple routes. For example, pushstate routing allows a single JavaScript file route to multiple anchor-tagged URLs that look like /some/path1 instead of /some#path1.