core.js:6014错误错误:未捕获(承诺):错误:无法匹配任何路由。网址段:“ qa”

时间:2019-09-23 04:31:39

标签: angular nginx kubernetes kubernetes-ingress nginx-location

点击http://host/qa后如何加载质量检查应用程序?

我在/(这可以正常工作!)上创建了服务于dev-angular应用程序的ingress.yaml,但是在点击/ qa路径后却出错。

我还修改了有角度的路线,并将其重新部署到k8s。仍然出现相同的错误。我正在使用nginx将我的静态页面提供给nginx。开发和测试应用程序均使用nginx文件提供。

角度app.module.ts代码:

const Routes = [
  {
    path: '',
    redirectTo: 'login',
    pathMatch: 'full'
  },
  {
    path: 'qa', redirectTo: 'login'
  },
  {
    path: 'login', component: LoginComponent
  },
  {
    path: 'search', component: SearchComponent, canActivate: [AuthGuard],
  },
  {
    path: 'feedback', component: FeedbackComponent, canActivate: [AuthGuard],
  },
  {
    path: 'details', component: DetailsComponent, canActivate: [AuthGuard],
  },
  {
    path: 'results', component: ResultsComponent, canActivate: [AuthGuard],
  }
];

@NgModule({
  declarations: [
    AppComponent,
    PostsComponent,
    SearchComponent,
    ResultsComponent,
    DetailsComponent,
    FeedbackComponent,
    FeedbackDialogComponent,
    LoginComponent,
    ProfileDialogComponent,
    DialogComponent,
    DetailsDialogComponent
  ],
  entryComponents: [
    FeedbackDialogComponent,
    ProfileDialogComponent,
    DialogComponent,
    DetailsDialogComponent
  ],
  imports: [
    BrowserModule,
    HttpClientModule,
    HttpModule,
    RouterModule.forRoot(Routes),
    AppRoutingModule,
    BrowserAnimationsModule,
    MaterialModule,
    FormsModule,
    ReactiveFormsModule,
    NgbModule
  ],
  providers: [
    PostsService,
    LoginService,
    SearchService,
    FeedbackDialogService,
    HeaderHelper,
    SearchDataService,
    DetailsService,
    ResultDataService,
    ResultsService
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

Nginx conf文件

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    server {
        listen 80;

        root   /usr/share/nginx/html;
        index  index.html index.htm;
        include /etc/nginx/mime.types;

        gzip on;
        gzip_min_length 1000;
        gzip_proxied expired no-cache no-store private auth;
        gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        location / {
            try_files $uri $uri/ /index.html;
        }
    }
}

Kubernetes入口文件-

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: project-rules
  annotations:
    ingress.bluemix.net/rewrite-path: "serviceName=<dev-service> rewrite=/;serviceName=<qa-service> rewrite=/"
spec:
  tls:
  - hosts:
    - <>
    secretName: <secret>
  rules:
  - host: <>
    http:
      paths:
       - path: /
         backend:
           serviceName: dev-service
           servicePort: 80
       - path: /qa
         backend:
           serviceName: qa-service
           servicePort: 80

我收到的错误消息是-

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'qa'
Error: Cannot match any routes. URL Segment: 'qa'
    at ApplyRedirects.noMatchError (router.js:4297)
    at CatchSubscriber.selector (router.js:4261)
    at CatchSubscriber.error (catchError.js:29)
    at MapSubscriber._error (Subscriber.js:75)
    at MapSubscriber.error (Subscriber.js:55)
    at MapSubscriber._error (Subscriber.js:75)
    at MapSubscriber.error (Subscriber.js:55)
    at MapSubscriber._error (Subscriber.js:75)
    at MapSubscriber.error (Subscriber.js:55)
    at ThrowIfEmptySubscriber._error (Subscriber.js:75)
    at resolvePromise (zone-evergreen.js:797)
    at resolvePromise (zone-evergreen.js:754)
    at zone-evergreen.js:858
    at ZoneDelegate.invokeTask (zone-evergreen.js:391)
    at Object.onInvokeTask (core.js:39679)
    at ZoneDelegate.invokeTask (zone-evergreen.js:390)
    at Zone.runTask (zone-evergreen.js:168)
    at drainMicroTaskQueue (zone-evergreen.js:559)

0 个答案:

没有答案