0

I´m getting the wellknown "Error: Cannot match any routes." in angular only on my Prod machine, on my local Visual studio dev it is working just fine...

The strange thing is that I have defined path '**', but still get this error. The path to the actual page is "admin/Forms/Index/19130" where "Forms" is the root. So I have also tried path 'Forms/index/:Id' without any success.

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { getParamsService } from 'ClientApp/Shared/getParamsService';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { DataService } from 'ClientApp/Shared/dataService';
import { tokenResponseService } from 'ClientApp/Shared/tokenResponseService';
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
import { TokenInterceptorService } from 'ClientApp/Shared/token-interceptor.service';
import { ReactiveFormsModule } from '@angular/forms';

let routes = [
    { path: '**', component: AppComponent },
]


@NgModule({
  declarations: [
     AppComponent
  ],
  imports: [
      BrowserModule,
      HttpClientModule,
      AppRoutingModule,
      RouterModule.forRoot(routes, { useHash: false, enableTracing: false })
    ],
    providers: [getParamsService,
        { provide: HTTP_INTERCEPTORS, useClass: TokenInterceptorService, multi: true },
        DataService,
        tokenResponseService],
    bootstrap: [AppComponent]
})
export class AppModule { }

this works on my dev machine

let routes = [
    { path: '', component: AppComponent },
    { path: 'Forms/Index/:id', component: AppComponent },
]

But on the prod server I get "Error: Cannot match any routes."

Any help is appreciated

Thanks in advance

Andreas
  • 1
  • 1
  • What component you are bootstrapping? Can you provide your entire `AppModule` declaration. Also provide the component you are bootstrapping. – Pankaj Prakash Mar 05 '21 at 10:16
  • Hi! I am bootstrapping my netcore client.. it´s just a blank cshtml page with the angular loaded into it – Andreas Mar 05 '21 at 10:25
  • https://stackoverflow.com/questions/37693411/cannot-match-any-routes This might be help you – Parth Raval Mar 05 '21 at 10:28
  • hm.. I have on my page and the error is saying Cannot match any routes. URL Segment: 'admin/Forms/Index/19130' ... but shouldn´t '**' match all urls? I´m confused – Andreas Mar 05 '21 at 10:45

0 Answers0