【发布时间】:2018-02-02 04:18:09
【问题描述】:
我有一个 Angular 应用程序。我运行命令ng build --prod --aot 来生成 dist 文件夹。
在 dist 文件夹中,我创建了一个名为 Staticfile 的文件,然后我使用以下命令将 dist 文件夹上传到 pivotal.io:
- cf push name-app --no-start
- cf start name-app
应用程序运行良好。我有一个导航栏,所以当我使用导航栏更改路径时,一切正常。但是当我手动操作时(我自己输入 url)我有这个错误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');
}
}
【问题讨论】:
-
关注stackoverflow.com/a/40833154 更新您的 nginx 配置文件
标签: angular nginx single-page-application angular-routing cloud-foundry