core.js:6014 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'qa'

9/23/2019

How can I load qa application after hitting http://host/qa?

I created ingress.yaml serving dev-angular application on / (Which is working fine!) but getting error after hitting /qa path.

I modified routes in angular as well and redeployed application to k8s. Still getting same error. I'm using nginx to serve my static pages to nginx. Both dev and test app is served using nginx files.

Angular app.module.ts code :

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 file

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 Ingress file -

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 message I got is -

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)
-- Chinmay Kulkarni
angular
kubernetes
kubernetes-ingress
nginx
nginx-location

0 Answers