我有一个Angular应用程序。我运行命令ng build --prod --aot
来生成dist文件夹。 在dist文件夹中,我创建了一个名为Staticfile文件,然后我上传dist文件夹到pivotal.io用下面的命令:404未找到nginx角度4路由
- CF推名称应用--no启动
- CF启动名称 - 应用程序
该应用程序运行良好。我有一个导航栏,所以当我用navbar改变路径时,一切正常。但当我手动(我自己输入网址)我有这个错误404 Not Found nginx。 这是我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');
}
}
编辑
是静态编译不适合我的应用?角度应用程序准备就绪后应该做什么?你所有的回应都假设我已经有了后端。你能仔细阅读我的文章吗?
按照此HTTPS发现某处:/ /stackoverflow.com/a/40833154更新你的nginx配置文件 – Brilliant