我在生产模式下重定向我的应用程序时遇到问题。当我有 url 时http://server.com/projectname/dashboard
,服务器响应 IIS 错误页面 404。我必须使用打开应用程序http://server.com/projectname
,然后单击链接,例如:
<a [routerLink]="'dashboard'">Dashboard</a>
在 html 我有<base href="./">
,这是我的路由器:
const appRoutes: Routes = [
{ path: '', redirectTo: 'dashboard', pathMatch: 'full', canActivate: [AuthGuard] },
{ path: 'dashboard', component: DashboardComponent, canActivate: [AuthGuard]},
{ path: '400', component: ErrorComponent, canActivate: [AuthGuard] },
{ path: '401', component: ErrorComponent, canActivate: [AuthGuard] },
{ path: '404', component: ErrorComponent, canActivate: [AuthGuard],
{ path: '**', redirectTo: '/404' }
]
@NgModule({
imports: [
RouterModule.forRoot(appRoutes)
]
})
在开发模式下,我有 url http://localhost:4200/dashboard
,我应该重定向。在开发中是 url localhost:4200/dashboard 而在生产中是 server.com/ appname /dashboard 会不会有问题?